frankenphp
frankenphp copied to clipboard
Death of worker causes panic
I attempted a very simple implementation of restarting a worker on a file change:
<?php
$startup = hash_file('crc32', __FILE__);
do {
$running = frankenphp_handle_request(function (): void {
echo "hi!!";
var_dump(hash_file('crc32', __FILE__));
});
if (hash_file('crc32', __FILE__) !== $startup) {
error_log('rebooting');
die();
}
} while ($running);
This causes a panic in frankenphp:
{"level":"info","ts":1666099933.9751377,"msg":"rebooting","syslog_level":"notice"}
{"level":"info","ts":1666099933.9752717,"logger":"http.log.access","msg":"handled request","request":{"remote_ip":"172.17.0.1","remote_port":"47406","proto":"HTTP/2.0","method":"GET","host":"localhost","uri":"/","headers":{"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.47"],"Sec-Fetch-Dest":["document"],"Cache-Control":["max-age=0"],"Sec-Ch-Ua-Mobile":["?0"],"Upgrade-Insecure-Requests":["1"],"Accept-Encoding":["gzip, deflate, br"],"Accept-Language":["en-US,en;q=0.9"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Dnt":["1"],"Sec-Fetch-Mode":["navigate"],"Sec-Fetch-User":["?1"],"Sec-Ch-Ua":["\"Chromium\";v=\"106\", \"Microsoft Edge\";v=\"106\", \"Not;A=Brand\";v=\"99\""],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"],"Sec-Fetch-Site":["none"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"localhost"}},"user_id":"","duration":0.000535418,"size":24,"status":200,"resp_headers":{"Content-Type":["text/html; charset=UTF-8"],"Server":["Caddy"],"Alt-Svc":["h3=\":443\"; ma=2592000"],"X-Powered-By":["PHP/8.2.0-dev"]}}
{"level":"error","ts":1666099933.975745,"msg":"unexpected termination, restarting","worker":"/app/public/index.php"}
{"level":"error","ts":1666099933.9771106,"msg":"unexpected termination, restarting","worker":"/app/public/index.php"}
panic: sync: negative WaitGroup counter
goroutine 117 [running, locked to thread]:
sync.(*WaitGroup).Add(0x48cf46?, 0x1e3ad80?)
/usr/local/go/src/sync/waitgroup.go:83 +0xda
sync.(*WaitGroup).Done(...)
/usr/local/go/src/sync/waitgroup.go:108
github.com/dunglas/frankenphp.go_frankenphp_worker_ready(...)
/go/src/app/worker.go:111
github.com/dunglas/frankenphp._Cfunc_frankenphp_execute_script(0x76b43c08dec0)
_cgo_gotypes.go:769 +0x48
github.com/dunglas/frankenphp.go_execute_script(0xc0000e8301?)
/go/src/app/frankenphp.go:385 +0x237