1

I have deployment (capistrano) that, on success, reloads systemd:

sudo systemctl reload myserver.service

But, just after the first deploy, the service is not yet running. In that case, I want to start it, instead.

sudo systemctl start myserver.service

Is there a flag or other trick in systemd that figures out: "is the service running, then reload, otherwise, start it"? The alternative would be to build this into the deployment tooling itself, but I'd rather use existing features if systemd provides these.

4

You probably mixed something up. The command to reload or start a systemd service is systemctl.
You can try

sudo systemctl reload-or-restart myserver.service

That should do what You asked for.

  • Sorry about the confusion: I have systemctl aliased to systemd. Because I keep mixing up systemctl with sysctl. But it seems the reload-or-restart does what I want it to do. – berkes Oct 20 '19 at 16:41

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.