Closed iacore closed 5 months ago
I had the need to use dinitctl start X || dinitctl restart X for a few times now.
Well, dinitctl start X
doesn't return an error if the service is already running. It should be the other way around: dinitctl restart X || dinitctl start X
- maybe that's what you meant? Another option would be dinitctl stop X; dinitctl start X
.
Just to make sure I understand correctly: the complaint is just that you need two commands?
I also have trouble understanding why dinitctl restart X doesn't start a service if it has not started.
Because "restart" is not the same as "stop" + "start". There was a discussion about this a little while back but I can't find it now.
dinitctl start
marks a service as active.
dinitctl restart
doesn't mark a service active; it restarts a running service whether it is active or not (if it's not active, the only reason it would be running is if it has a running dependent). Since a non-active service shouldn't run, it doesn't make sense for "restart" to start a not-started service.
The earlier discussion was here: https://github.com/davmac314/dinit/issues/300
Can you move this to Discussion?
I think I don't understand how dependency / active state works in dinit. I usually just do dinitctl enable X
.
man dinitctl
says:
list List loaded services and their state. Before each service, one of the following state indicators is
displayed:
...
square brackets are used if the service is marked active (target state will always be started if this is the case).
I don't see square brackets in the output of dinitctl list
, so I think my services are not "active"?
Is your feature request related to a problem? Please describe.
I had the need to use
dinitctl start X || dinitctl restart X
for a few times now.When developing an application, and that application also runs under dinit, sometimes it crashes. I need a command to start a new version of the application (in build script) no matter if it was running or not.
I also have trouble understanding why
dinitctl restart X
doesn't start a service if it has not started.Describe the solution you'd like
dinitctl start --stop-if-running X