/
passenger
47 lines (38 loc) · 1.51 KB
/
passenger
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/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