diff --git a/plugins/psgi/psgi_plugin.c b/plugins/psgi/psgi_plugin.c index 10cb902b..599ebe98 100644 --- a/plugins/psgi/psgi_plugin.c +++ b/plugins/psgi/psgi_plugin.c @@ -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}, };