Thursday, April 25, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 2632  / 1 Year ago, sun, january 15, 2023, 4:00:43

I have an init.d script for nginx that normally works fine. However, after a reboot it doesn't work properly and the worker process would die leaving just the master process.



nginx has some mongodb stuff (nginx-gridfs) compiled in and needs to start after mongodb which is being started by upstart.



That's all I've been able to figure out after some troubleshooting. I believe I have to change over nginx to upstart and make it dependent on mongo. How can I do that?


More From » upstart

 Answers
7

Since nginx-gridfs connects to mongodb, the db server should already be running and ready. This was causing a problem.
First I removed the /etc/init.d/nginx script using 'update-rc.d remove nginx'
Then I created an 'upstart' script in /etc/init/nginx.conf :



# nginx

description "nginx http daemon"

#start on mongodb
start on (local-filesystems
and net-device-up IFACE=lo
and started mongodb)
stop on stopped mongodb

env DAEMON=/usr/local/nginx/sbin/nginx
env PID=/usr/local/nginx/logs/nginx.pid

expect fork
respawn
respawn limit 10 5

pre-start script
$DAEMON -t
if [ $? -ne 0 ]
then exit $?
fi
# Add a sleep of 10 sec. to allow mongodb to finish starting up
sleep 10
end script

exec $DAEMON


This fixed the problem for me.


[#34106] Monday, January 16, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
uxuriousrnal

Total Points: 279
Total Questions: 106
Total Answers: 96

Location: Fiji
Member since Wed, Mar 29, 2023
1 Year ago
uxuriousrnal questions
Wed, Mar 9, 22, 09:04, 2 Years ago
Mon, Jul 18, 22, 01:48, 2 Years ago
Wed, Apr 13, 22, 01:15, 2 Years ago
Thu, Aug 26, 21, 22:01, 3 Years ago
;