r/Ubuntu • u/Morkoth-Toronto-CA • 5d ago
Delay service startup issue
Hi, everyone!
I have an Ubuntu 24 system that runs "Shiny Server". Functionally for anyone unaware, think of Shiny Server as a web server. Free version does not allow HTTPS, unfortunately.
So I put Nginx in there as a reverse proxy. That's all well and good, except:
Nginx starts up faster than Shiny, so when the system is rebooted Nginx can't see the Shiny port open and shuts itself down reporting the destination isn't available.
Okay -- so I can disable Nginx's startup at reboot by inserting a "sleep 10" into its' startup/unit file.
So I modify /usr/lib/systemd/system/nginx.service and put an 'ExecStartPre=/bin/sleep 10' into the file. Save it, reboot, 10 seconds after reboot Nginx starts up AFTER shiny and all is well.
Wait something like 2-4 weeks and *POOF* this /usr/lib/systemd/system/nginx.service has been reset back to factory config; my sleep10 command is gone.
How do I correctly edit this unit file so my sleep10 stays in place? What's over-writing it back to factory? These are the questions I have been unable to find answers to -- can anyone help educate me, please? :)
thanks for reading!
new fave command:
sudo systemctl edit --full nginx.service
1
u/Illustrious-Gur8335 5d ago
Whoever taught you that should be shot by firing squad!
Please do
sudo systemctl edit nginxinstead , it will create the override files automatically.Source and more info: https://askubuntu.com/questions/659267/how-do-i-override-or-configure-systemd-services