コード例 #1
0
int uwsgi_python_mount_app(char *mountpoint, char *app, int regexp) {

	int id;

	if (strchr(app, ':') || uwsgi_endswith(app, ".py") || uwsgi_endswith(app, ".wsgi")) {
		uwsgi.wsgi_req->appid = mountpoint;
		uwsgi.wsgi_req->appid_len = strlen(mountpoint);
		if (uwsgi.single_interpreter) {
			id = init_uwsgi_app(LOADER_MOUNT, app, uwsgi.wsgi_req, up.main_thread, PYTHON_APP_TYPE_WSGI);
		}
		else {
			id = init_uwsgi_app(LOADER_MOUNT, app, uwsgi.wsgi_req, NULL, PYTHON_APP_TYPE_WSGI);
		}

#ifdef UWSGI_PCRE
	int i;
	if (regexp && id != -1) {
		struct uwsgi_app *ua = &uwsgi_apps[id];
		uwsgi_regexp_build(mountpoint, &ua->pattern, &ua->pattern_extra);
		if (uwsgi.mywid == 0) {
			for(i=1;i<=uwsgi.numproc;i++) {
				uwsgi.workers[i].apps[id].pattern = ua->pattern;
				uwsgi.workers[i].apps[id].pattern_extra = ua->pattern_extra;
			}
		}
	}
#endif

		return id;
	}
	return -1;

}
コード例 #2
0
ファイル: alarm.c プロジェクト: JuanS/uwsgi
static int uwsgi_alarm_log_add(char *alarms, char *regexp, int negate) {

	struct uwsgi_alarm_log *old_ual = NULL, *ual = uwsgi.alarm_logs;
	while (ual) {
		old_ual = ual;
		ual = ual->next;
	}

	ual = uwsgi_calloc(sizeof(struct uwsgi_alarm_log));
	if (uwsgi_regexp_build(regexp, &ual->pattern, &ual->pattern_extra)) {
		return -1;
	}
	ual->negate = negate;

	if (old_ual) {
		old_ual->next = ual;
	}
	else {
		uwsgi.alarm_logs = ual;
	}

	// map instances to the log
	char *list = uwsgi_str(alarms);
	char *p = strtok(list, ",");
	while (p) {
		struct uwsgi_alarm_instance *uai = uwsgi_alarm_get_instance(p);
		if (!uai) {
			free(list);
			return -1;
		}
		struct uwsgi_alarm_ll *old_uall = NULL, *uall = ual->alarms;
		while (uall) {
			old_uall = uall;
			uall = uall->next;
		}

		uall = uwsgi_calloc(sizeof(struct uwsgi_alarm_ll));
		uall->alarm = uai;
		if (old_uall) {
			old_uall->next = uall;
		}
		else {
			ual->alarms = uall;
		}
		p = strtok(NULL, ",");
	}
	free(list);
	return 0;
}