preapre for psgi early-exec

This commit is contained in:
Roberto De Ioris
2014-05-08 07:26:31 +02:00
parent 7c1bd05dd2
commit 5ffd5f9bb9
+12 -1
View File
@@ -33,6 +33,16 @@ static void uwsgi_opt_early_psgi(char *opt, char *value, void *foobar) {
if (!uperl.early_psgi_callable) exit(1);
}
EXTERN_C void xs_init (pTHX);
static void uwsgi_opt_early_exec(char *opt, char *value, void *foobar) {
uwsgi_perl_init();
perl_parse(uperl.main[0], xs_init, 3, uperl.embedding, NULL);
SV *dollar_zero = get_sv("0", GV_ADD);
sv_setsv(dollar_zero, newSVpv(value, strlen(value)));
uwsgi_perl_exec(value);
}
struct uwsgi_option uwsgi_perl_options[] = {
{"psgi", required_argument, 0, "load a psgi app", uwsgi_opt_set_str, &uperl.psgi, 0},
@@ -53,7 +63,8 @@ struct uwsgi_option uwsgi_perl_options[] = {
{"plshell-oneshot", no_argument, 0, "run a perl interactive shell (one shot)", uwsgi_opt_plshell, NULL, 0},
{"perl-no-plack", no_argument, 0, "force the use of do instead of Plack::Util::load_psgi", uwsgi_opt_true, &uperl.no_plack, 0},
{"early-psgi", required_argument, 0, "load a psgi app soon after perl initialization", uwsgi_opt_early_psgi, NULL, UWSGI_OPT_IMMEDIATE},
{"early-psgi", required_argument, 0, "load a psgi app soon after uWSGI initialization", uwsgi_opt_early_psgi, NULL, UWSGI_OPT_IMMEDIATE},
{"early-perl-exec", required_argument, 0, "load a perl script soon after uWSGI initialization", uwsgi_opt_early_exec, NULL, UWSGI_OPT_IMMEDIATE},
{0, 0, 0, 0, 0, 0, 0},
};