Graceful/no-downtime restart with systemd startup method?

I followed the instructions here to configure my pod to start using systemd, and it seems to work OK. But the problem I am having is that there does not appear to be a way to restart the service without any downtime (that is, without a load-balanced front end):

sudo systemctl restart diaspora.target

or

sudo systemctl restart diaspora-web.service

Both cause the service to go down for a minute or so, during which requests cannot be processed. What do I need to do in order to make it work like as described in the FAQ for Pod maintainers:

In production mode, it’s possible to do a graceful restart of the Unicorn process to avoid downtime. This command, executed in the directory of your diaspora installation, will spawn a new master process, loading any code/configuration changes that you’ve made:

RAILS_ENV=production bin/eye restart web

(If I issue the above, then I am getting this error:

diaspora@pod:~/diaspora$ RAILS_ENV=production bin/eye restart web 
socket (/home/diaspora/.eye/sock) not found, did you run `eye load`?

.)

I am still learning; hopefully this is not a stupid question :slight_smile:

You can send unicorn a USR2 signal to restart it gracefully (that’s what eye does too). This can be done by adding ExecReload=/bin/kill -USR2 $MAINPID to the service file. Also make sure to have PIDFile=/path/to/diaspora/tmp/pids/web.pid (replace /path/to/diaspora) so systemd finds the new PID after the reload.

When you don’t use eye to start the service then you can’t use it for restarting it.

Thank you! I made this change this afternoon, and it works great.

1 Like