mirror of
https://github.com/safing/portmaster
synced 2025-09-02 02:29:12 +00:00
Improve starting and stopping
This commit is contained in:
parent
34894ea7d6
commit
2d0d711938
4 changed files with 12 additions and 16 deletions
|
@ -29,6 +29,7 @@ var (
|
|||
|
||||
func init() {
|
||||
// Add Go's default flag set.
|
||||
// TODO: Move flags throughout Portmaster to here and add their values to the service config.
|
||||
rootCmd.Flags().AddGoFlagSet(flag.CommandLine)
|
||||
|
||||
// Add persisent flags for all commands.
|
||||
|
|
|
@ -36,10 +36,8 @@ func cmdRun(cmd *cobra.Command, args []string) {
|
|||
|
||||
// SETUP
|
||||
|
||||
svcCfg.VerifyBinaryUpdates = nil // FIXME
|
||||
svcCfg.VerifyIntelUpdates = nil // FIXME
|
||||
|
||||
// enable SPN client mode
|
||||
// Enable SPN client mode.
|
||||
// TODO: Move this to service config.
|
||||
conf.EnableClient(true)
|
||||
conf.EnableIntegration(true)
|
||||
|
||||
|
@ -97,18 +95,14 @@ func cmdRun(cmd *cobra.Command, args []string) {
|
|||
// Wait for shutdown to be finished.
|
||||
select {
|
||||
case <-instance.ShutdownComplete():
|
||||
// Print stack on shutdown, if enabled.
|
||||
if printStackOnExit {
|
||||
printStackTo(os.Stdout, "PRINTING STACK ON EXIT")
|
||||
}
|
||||
case <-time.After(3 * time.Minute):
|
||||
printStackTo(os.Stderr, "PRINTING STACK - TAKING TOO LONG FOR SHUTDOWN")
|
||||
}
|
||||
|
||||
// Stop logging.
|
||||
log.Shutdown()
|
||||
|
||||
// Print stack on shutdown, if enabled.
|
||||
if printStackOnExit {
|
||||
printStackTo(os.Stdout, "PRINTING STACK ON EXIT")
|
||||
}
|
||||
|
||||
// Check if restart was triggered and send start service command if true.
|
||||
if instance.ShouldRestart && service.IsService() {
|
||||
if err := service.RestartService(); err != nil {
|
||||
|
@ -116,6 +110,9 @@ func cmdRun(cmd *cobra.Command, args []string) {
|
|||
}
|
||||
}
|
||||
|
||||
// Stop logging.
|
||||
log.Shutdown()
|
||||
|
||||
// Give a small amount of time for everything to settle:
|
||||
// - All logs written.
|
||||
// - Restart command started, if needed.
|
||||
|
|
|
@ -52,6 +52,8 @@ func (s *LinuxSystemService) Run() {
|
|||
wait:
|
||||
for {
|
||||
select {
|
||||
case <-s.instance.ShuttingDown():
|
||||
break wait
|
||||
case sig := <-signalCh:
|
||||
// Only print and continue to wait if SIGUSR1
|
||||
if sig == syscall.SIGUSR1 {
|
||||
|
@ -64,8 +66,6 @@ wait:
|
|||
s.instance.Shutdown()
|
||||
break wait
|
||||
}
|
||||
case <-s.instance.ShuttingDown():
|
||||
break wait
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,8 +24,6 @@ func init() {
|
|||
|
||||
func update(cmd *cobra.Command, args []string) error {
|
||||
// Finalize config.
|
||||
svcCfg.VerifyBinaryUpdates = nil // FIXME
|
||||
svcCfg.VerifyIntelUpdates = nil // FIXME
|
||||
err := svcCfg.Init()
|
||||
if err != nil {
|
||||
return fmt.Errorf("internal configuration error: %w", err)
|
||||
|
|
Loading…
Add table
Reference in a new issue