-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart-nginx
executable file
·39 lines (33 loc) · 1.02 KB
/
start-nginx
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
#!/usr/bin/env bash
psmgr=/tmp/nginx-buildpack-wait
rm -f $psmgr
mkfifo $psmgr
#Evaluate config to get $PORT
erb config/nginx.conf.erb > config/nginx.conf
#Initialize log directory.
mkdir -p logs/nginx
touch logs/nginx/access.log logs/nginx/error.log
echo 'buildpack=nginx at=logs-initialized'
#Start log redirection.
(
#Redirect NGINX logs to stdout.
tail -qF -n 0 logs/nginx/*.log
echo 'logs' >$psmgr
) &
#Start NGINX
(
#We expect nginx to run in foreground.
#We also expect a socket to be at /tmp/nginx.socket.
echo 'buildpack=nginx at=nginx-start'
bin/nginx -p . -c config/nginx.conf
echo 'nginx' >$psmgr
) &
#This read will block the process waiting on a msg to be put into the fifo.
#If any of the processes defined above should exit,
#a msg will be put into the fifo causing the read operation
#to un-block. The process putting the msg into the fifo
#will use it's process name as a msg so that we can print the offending
#process to stdout.
read exit_process <$psmgr
echo "buildpack=nginx at=exit process=$exit_process"
exit 1