Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
48 lines (38 sloc) 1.51 KB
#!/bin/bash
# Inject environment variables into pool
sed -i '/^env\[.\+\] *=.*/d' /etc/php/7.2/fpm/pool.d/www.conf
env | grep -v ^PASSENGER_ | grep -v =$ | sed 's/\([^=]\+\)=\(.*\)/env[\1]=\"\2\"/' | awk 'length <= 1024' >> /etc/php/7.2/fpm/pool.d/www.conf
# Enable Xdebug (and other PHP-recommended directives) in development mode
if [ "$APPLICATION_ENV" == "dev" ]; then
phpenmod xdebug && cp -f /usr/lib/php/7.2/php.ini-development /etc/php/7.2/fpm/php.ini
else
phpdismod xdebug && cp -f /usr/lib/php/7.2/php.ini-production /etc/php/7.2/fpm/php.ini
fi
# Start PHP-FPM
/etc/init.d/php7.2-fpm start
# Default to production mode
PASSENGER_ENVIRONMENT="production"
# Restart application after every request in development mode
if [ "$APPLICATION_ENV" == "dev" ]; then
mkdir -p tmp && touch tmp/always_restart.txt
PASSENGER_ENVIRONMENT="development"
fi
# Set file-creation mask
umask 0077
# Configure Passenger, as per https://www.phusionpassenger.com/library/config/standalone/reference/
PASSENGER_ENVIRONMENT="$PASSENGER_ENVIRONMENT" \
PASSENGER_GROUP=www-data \
PASSENGER_LOG_FILE=/var/log/passenger.log \
PASSENGER_NGINX_CONFIG_TEMPLATE=/usr/local/etc/nginx.conf.erb \
PASSENGER_PID_FILE=/var/run/passenger.pid \
PASSENGER_PORT=8080 \
PASSENGER_PYTHON=python3 \
PASSENGER_TURBOCACHING=false \
PASSENGER_USER=www-data \
/usr/local/bin/passenger "$@"
# Remove tmp/always_restart.txt in development mode
if [ "$APPLICATION_ENV" == "dev" ]; then
rm -f tmp/always_restart.txt
fi
# Stop PHP-FPM
/etc/init.d/php7.2-fpm stop