1

I needed to make a new image and opted for the new 16.04 ubuntu so I could get newer versions of some packages and not install from source. So far, I regret that decision as online docs are sparse.

With 12.04 and 14.04, I was often able to re-purpose the startup scripts for custom compilations by installing a package, then removeing (not purging) it, to create the ubuntu startup scripts. Then I could just edit them to point to the right config file and binary.

For example, to use the latest openresty I could just do this:

apt-get install nginx
apt-get remove nginx

Then I could just update the /etc/init.d/nginx script to point to my custom binary/config file and I have a happy ubuntu startup script. Great!

This method doesn't work with 16.04 anymore.

I've edited:

  • /etc/init.d/nginx
  • /etc/init/nginx.conf
  • /lib/system.d/system/nginx.service

ubuntu never pulls my binary (which is in /usr/local/openresty/nginx/sbin/nginx). it always runs /sbin/nginx on bootup (i missed uninstalling 'nginx-core' at first) or nothing at all. The same holds true for other packages.

Ubuntu's docs on the transition from upstart are lacking in this area, they're concerned with "start stop".

I have no idea where ubuntu is deciding this. i can't find any config files that point to /sbin/nginx. No logs help. Every potential file I've come across points to the alternate binary and config.

If anyone can share a good resource on using the new launch system and where it looks/store info, I would be incredibly grateful.

There seems to be a database involved, as it's detected file-changes and asked me to reload -- but I haven't found it.

update

after toying around a lot, I figured the following out:

It seems that the nginx package installed two types of setups but only uses one. some issues were tied to that.

  1. /etc/init.d/nginx and /etc/init/nginx.conf
  2. /lib/systemd/system/nginx.service and /etc/systemd/system/nginx.service

from trial and error: * run systemctl disable nginx.service to disable/delete most links and files * remove file in /etc/systemd/system/nginx.service if it exists * place a new file in /lib/systemd/system/nginx.service * run systemctl enable nginx.service

the file in /lib/systemd/system/nginx.service must be a file; it can't be symlink (otherwise a too many symlinks error appears)

this seems to work for now. i wish i could use symlinks as these files are tied to version control.

  • The systemd project page freedesktop.org/wiki/Software/systemd links to a a number of tutorials and documentation where the blog posts "systemd for administrators" series is a good start. – HBruijn Apr 27 '16 at 6:34
5

Could you create a new service for your custom install, then make it autostart?

[Unit]
Description=Jonathan Vanasco nginx

[Service]
ExecStart=STARTUP COMMAND YOU WANT FOR CUSTOM

[Install]
WantedBy=multi-user.target

Then check it starts:

systemctl start NAMEOFCUSTOM.service

Then set to auto-start on boot:

systemctl enable NAMEOFCUSTOM.service

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.