diff --git a/cmds/portmaster-core/main.go b/cmds/portmaster-core/main.go index eb677a47..993ffb55 100644 --- a/cmds/portmaster-core/main.go +++ b/cmds/portmaster-core/main.go @@ -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. diff --git a/cmds/portmaster-core/run.go b/cmds/portmaster-core/run.go index 4c11a1cd..33702992 100644 --- a/cmds/portmaster-core/run.go +++ b/cmds/portmaster-core/run.go @@ -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. diff --git a/cmds/portmaster-core/run_linux.go b/cmds/portmaster-core/run_linux.go index 7859ed26..9b65b804 100644 --- a/cmds/portmaster-core/run_linux.go +++ b/cmds/portmaster-core/run_linux.go @@ -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 } } diff --git a/cmds/portmaster-core/update.go b/cmds/portmaster-core/update.go index a3158dea..31fcb881 100644 --- a/cmds/portmaster-core/update.go +++ b/cmds/portmaster-core/update.go @@ -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)