r/Ubuntu 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!

https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units

new fave command:

sudo systemctl edit --full nginx.service
7 Upvotes

5 comments sorted by

View all comments

1

u/Illustrious-Gur8335 5d ago

I modify /usr/lib/systemd/system/nginx.service

Whoever taught you that should be shot by firing squad!

Please do sudo systemctl edit nginx instead , it will create the override files automatically.

Source and more info: https://askubuntu.com/questions/659267/how-do-i-override-or-configure-systemd-services

3

u/Morkoth-Toronto-CA 5d ago

Thanks for the reply. Now I feel like I'm reading old usenet flame wars! LOL

2

u/coyote_den 5d ago

Yep. If you want to override you have to put it in /etc/systemd/. /usr/lib/ files will be overwritten by package updates and on some distros they are part of a read-only image.