s2i-php-container
s2i-php-container copied to clipboard
Document how to run PHP servers directly
I was looking for the best way to launch a PHP script which is itself a long-lived server process.
Rather than replacing the S2I run script entirely, I created a php-pre-start/99-artisan-ws.sh script:
#!/bin/bash
# This script is sourced by the s2i run script just before Apache httpd would
# be executed. If the ARTISAN_WS environment variable is set then the
# WebSocket server is launched instead of Apache httpd.
if [[ -z $ARTISAN_WS ]]; then
return 0
fi
exec php artisan websockets:serve
# If we reach this point, we weren't able to run the WebSocket server. We want
# the container to die rather than continue to run Apache httpd.
exit 1
If that looks sane then how about documenting this approach?