Repository navigation
feat: quitting Flock stops it, and a stopped Flock stays stopped #219
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
Changes from all commits
cd322de
bbfcf2c
104e41b
5f79f00
af68c1e
86c30e8
0e1dd8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,11 @@ func newInstallCommand() *cobra.Command { | |
| } | ||
| } | ||
|
|
||
| // Until the first install gets through its privileged steps, Flock isn't set up: the apps | ||
| // take a registered daemon for a finished setup (Installation.isSetUp, IsSetUp). Read | ||
| // before those steps, which register the daemon on Linux. | ||
| firstInstall := !serviceInstalled() | ||
|
|
||
| // With privilegedFirst, the steps that need an administrator come before anything is | ||
| // replaced: declining them leaves the installed version as it was. | ||
| var ca *certs.CA | ||
|
|
@@ -93,13 +98,20 @@ func newInstallCommand() *cobra.Command { | |
| cmd.Printf("! could not update your shell profile: %v\n", err) | ||
| } | ||
|
|
||
| // Until the first install gets through its privileged steps, Flock isn't set up: the apps | ||
| // take a registered daemon for a finished setup (Installation.isSetUp, IsSetUp). | ||
| firstInstall := !serviceInstalled() | ||
| if firstInstall { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Capture first-install state before privileged setup. On Linux, Capture
|
||
| // A setup turns Flock on; an update leaves a stopped Flock stopped. | ||
| if err := clearStopped(s.root); err != nil { | ||
| return err | ||
| } | ||
| } | ||
| if err := installService(s.root, bin); err != nil { | ||
| return fmt.Errorf("install background service: %w", err) | ||
| } | ||
| cmd.Println("✓ daemon runs in the background and starts " + serviceStarts) | ||
| if isStopped(s.root) { | ||
| cmd.Println("✓ daemon is installed; Flock is stopped — `flock start` starts it") | ||
| } else { | ||
| cmd.Println("✓ daemon runs in the background and starts " + serviceStarts) | ||
| } | ||
|
|
||
| if skipPrivileged || privilegedFirst { | ||
| return nil | ||
|
|
||
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.
Drain the TCP server before closing shutdown connections.
For a TCP shutdown request,
writeJSONdoes not guarantee that the response has reached the caller. Small responses can remain buffered, andServer.Closecloses active connections. (go.dev)After this cancellation,
Rundrains only the Unix API server. Its deferredtcpServer.Close()can then close the TCP request before its response is flushed. The caller receives an error although shutdown succeeded.Gracefully drain both API servers before closing their connections.