php / php/frankenphp

How to reload FrankenPHP without restart to reresolve root directory

Open
#2,266 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
11.3k
Forks
488
Avg merge
4d 10h
Merged PRs (30d)
11

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked frankenphp-deployer-releases-reproducer and reproduce the symlink switch from releases/1 to releases/2. Compare the observed behavior after ./frankenphp reload, the Caddy admin reload, and the workers/restart request, using the provided curl checks. Done means FrankenPHP serves the new current release without downtime.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, php
Domain
backend, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.