Skip to content

How to reload FrankenPHP without restart to reresolve root directory #2266

@alexander-schranz

Description

@alexander-schranz

What happened?

In our Setup Infrastructure deployments and Code Deployments are completely separated in our setup.

We deploy code via deployer and need to reload FrankenPHP but FrankenPHP seems not work or reresolve the target directory.

Deployment via Deployer works via changed symlink. So webserver is targeting the current/public directory. And current is a symlink to the specific release so directory structure is something like:

 - current -> releases/1
 - releases
    - 1
       - public
          - index.php (Return `<h1>Release 1</h1>`)
          - test.txt (Return `Release 1`)
    - 2
       - public
          - index.php (Return `<h1>Release 2</h1>`)
          - test.txt (Return `Release 2`)

Here a reproducer repo, I'm running:

https://github.com/alexander-schranz/frankenphp-deployer-releases-reproducer

It basically works by switch the symlink:

# Release 1
ln -sfn releases/1 current
# Todo: reload FrankenPHP without any downtime?
curl -XGET http://127.0.0.1:8082/
curl http://127.0.0.1:8082/test.txt

# Release 2
ln -sfn releases/2 current
# Todo: reload FrankenPHP without any downtime?
curl -XGET http://127.0.0.1:8082/
curl http://127.0.0.1:8082/test.txt

Why the reproducer is created on MacOS, the Online / Production Infrastructure runs on Debian and FrankenPHP inside Docker. So the issue is unrelated to the OS or Static vs Docker Builds.

Image

What I tried:

./frankenphp reload
        # change resolve_root_symlink seems not effect frankenphp or caddy:
        resolve_root_symlink true
        resolve_root_symlink false
./frankenphp adapt --config Caddyfile | curl localhost:2019/load \
   -H "Content-Type: application/json" \
   -d @-
curl -X POST http://localhost:2019/frankenphp/workers/restart

Build Type

Static binary

Worker Mode

No

Operating System

macOS

CPU Architecture

Apple Silicon

PHP configuration

phpinfo() output
Reproducer uses binary from `curl https://frankenphp.dev/install.sh | sh`
without any custom php.ini.

Why we want use hard settings for opcache.

	# Recommended settings for Opcache used also for Nginx:
	# php_ini opcache.enable 1
	# php_ini opcache.revalidate_path 0
	# php_ini opcache.memory_consumption 256
	# php_ini opcache.max_accelerated_files 32531
	# php_ini opcache.validate_timestamps 0
	# php_ini opcache.revalidate_freq 0
	# php_ini realpath_cache_size 0
	# php_ini realpath_cache_ttl 600

Relevant log output

Relevant log output Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions