Skip to main content
added 4 characters in body
Source Link
berkes
  • 2.4k
  • 3
  • 18
  • 20

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

sudo systemdsystemctl 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 systemdsystemctl 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.

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

sudo systemd 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 systemd 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.

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.

Source Link
berkes
  • 2.4k
  • 3
  • 18
  • 20

How I can "start" if service is not running, but "reload" if it is running using systemd?

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

sudo systemd 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 systemd 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.