-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add restart cmd + auto/start, stop idempotency. #58
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approve (with the addition of README/tests for the $var
expanding in command).
} | ||
|
||
args, err := shlex.Split(service.Command) | ||
commandString := os.Expand(service.Command, func(k string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good change, but it doesn't look like it's documented (in the README
) or tested anywhere. Can we add those?
Nit: what about calling this commandExpanded
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah I forgot I had made this change, I'll make sure to add some tests and documentation.
@@ -134,6 +150,13 @@ func (m *ServiceManager) doStart(task *state.Task, tomb *tomb.Tomb) error { | |||
go func() { | |||
active.err = cmd.Wait() | |||
_ = active.logBuffer.Close() | |||
releasePlan, err := m.acquirePlan() | |||
if err == nil { | |||
if m.services[req.Name].cmd == cmd { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this if
statement check for? (I realize it was there already below.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
acquirePlan wouldn't actually fail here, since the plan is loaded already. I guess I can make this more future proof by relying on the mutex directly incase acquirePlan implementation changes.
e000d45
to
3fadf14
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. Just a few trivial remarks, and LGTM when you're happy.
startTasks.WaitAll(stopTasks) | ||
taskSet = state.NewTaskSet() | ||
taskSet.AddAll(stopTasks) | ||
taskSet.AddAll(startTasks) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's nice that both the stop order and the start order is correct here.
for id := range successors { | ||
id := string(string(id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a funny left over from an automatic replacement. The id used to be an ObjectId type.
Btw, please keep an eye on the commit message. The description of this PR looks out of date, referring to the env change which was split out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, sorry, one additional comment that probably needs looking into:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of trivials about error messages that became logs, and LGTM! Thank you!
This PR implements the
restart
command for (re)starting services.Additionally
Resolves #47