From c43f1f2f2e07c245876f1f7709d952ad24a9a144 Mon Sep 17 00:00:00 2001 From: Chris Umphress Date: Sat, 29 Jun 2024 06:44:09 -0500 Subject: [PATCH 1/3] Bare bones PHP support. --- piku.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/piku.py b/piku.py index 142e906..f58f045 100755 --- a/piku.py +++ b/piku.py @@ -409,6 +409,9 @@ def do_deploy(app, deltas={}, newrev=None): settings.update(deploy_clojure_cli(app, deltas)) elif exists(join(app_path, 'project.clj')) and found_app("Clojure Lein") and check_requirements(['java', 'lein']): settings.update(deploy_clojure_leiningen(app, deltas)) + elif 'php' in workers: + echo("-----> PHP app detected.", fg='green') + settings.update(deploy_identity(app, deltas)) elif 'release' in workers and 'web' in workers: echo("-----> Generic app detected.", fg='green') settings.update(deploy_identity(app, deltas)) @@ -741,7 +744,7 @@ def spawn_app(app, deltas={}): if exists(settings): env.update(parse_settings(settings, env)) # lgtm [py/modification-of-default-value] - if 'web' in workers or 'wsgi' in workers or 'jwsgi' in workers or 'static' in workers or 'rwsgi' in workers: + if 'web' in workers or 'wsgi' in workers or 'jwsgi' in workers or 'static' in workers or 'rwsgi' in workers or 'php' in workers: # Pick a port if none defined if 'PORT' not in env: env['PORT'] = str(get_free_port()) @@ -948,7 +951,7 @@ def spawn_app(app, deltas={}): env['PIKU_INTERNAL_NGINX_CUSTOM_CLAUSES'] = expandvars(open(join(app_path, env["NGINX_INCLUDE_FILE"])).read(), env) if env.get("NGINX_INCLUDE_FILE") else "" env['PIKU_INTERNAL_NGINX_PORTMAP'] = "" - if 'web' in workers or 'wsgi' in workers or 'jwsgi' in workers or 'rwsgi' in workers: + if 'web' in workers or 'wsgi' in workers or 'jwsgi' in workers or 'rwsgi' in workers or 'php' in workers: env['PIKU_INTERNAL_NGINX_PORTMAP'] = expandvars(NGINX_PORTMAP_FRAGMENT, env) env['PIKU_INTERNAL_NGINX_COMMON'] = expandvars(NGINX_COMMON_FRAGMENT, env) @@ -1158,6 +1161,19 @@ def spawn_worker(app, kind, command, env, ordinal=1): ('http-use-socket', '{BIND_ADDRESS:s}:{PORT:s}'.format(**env)), ('http-socket', '{BIND_ADDRESS:s}:{PORT:s}'.format(**env)), ]) + elif kind == 'php': + settings.extend([ + ('plugin', 'http,0:php'), + ('http', ':{}'.format(env['PORT'])), + ('static-skip-ext', '.php'), + ('static-skip-ext', '.inc'), + ('static-index', 'index.html'), + ('php-docroot', join(APP_ROOT, app, command.strip("/").rstrip("/"))), + ('php-allowed-ext', '.php'), + ('php-allowed-ext', '.inc'), + ('php-index', 'index.php'), + ('php-set', 'date.timezone=America/Chicago'), # TODO + ]) elif kind == 'web': echo("-----> nginx will talk to the 'web' process via {BIND_ADDRESS:s}:{PORT:s}".format(**env), fg='yellow') settings.append(('attach-daemon', command)) From 17eb21777d4c9718d7f039e81fdaea98c62ec865 Mon Sep 17 00:00:00 2001 From: Chris Umphress Date: Sat, 29 Jun 2024 13:38:08 -0500 Subject: [PATCH 2/3] Add support for custom php.ini directives. --- piku.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/piku.py b/piku.py index f58f045..cc8155c 100755 --- a/piku.py +++ b/piku.py @@ -1172,7 +1172,7 @@ def spawn_worker(app, kind, command, env, ordinal=1): ('php-allowed-ext', '.php'), ('php-allowed-ext', '.inc'), ('php-index', 'index.php'), - ('php-set', 'date.timezone=America/Chicago'), # TODO + ('php-ini-append', env["PHP_INI"]) if "PHP_INI" in env else None ]) elif kind == 'web': echo("-----> nginx will talk to the 'web' process via {BIND_ADDRESS:s}:{PORT:s}".format(**env), fg='yellow') From 9188327fb244201ecd9fa82b63b9e355fb7d3e8f Mon Sep 17 00:00:00 2001 From: Chris Umphress Date: Sun, 30 Jun 2024 21:38:42 -0500 Subject: [PATCH 3/3] Allow static files to be served through php worker. --- piku.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/piku.py b/piku.py index cc8155c..6b5867e 100755 --- a/piku.py +++ b/piku.py @@ -1162,17 +1162,17 @@ def spawn_worker(app, kind, command, env, ordinal=1): ('http-socket', '{BIND_ADDRESS:s}:{PORT:s}'.format(**env)), ]) elif kind == 'php': + docroot = join(APP_ROOT, app, command.strip("/").rstrip("/")) settings.extend([ ('plugin', 'http,0:php'), ('http', ':{}'.format(env['PORT'])), + ('check-static', docroot), ('static-skip-ext', '.php'), ('static-skip-ext', '.inc'), ('static-index', 'index.html'), - ('php-docroot', join(APP_ROOT, app, command.strip("/").rstrip("/"))), + ('php-docroot', docroot), ('php-allowed-ext', '.php'), - ('php-allowed-ext', '.inc'), - ('php-index', 'index.php'), - ('php-ini-append', env["PHP_INI"]) if "PHP_INI" in env else None + ('php-index', 'index.php') ]) elif kind == 'web': echo("-----> nginx will talk to the 'web' process via {BIND_ADDRESS:s}:{PORT:s}".format(**env), fg='yellow')