@@ -53,18 +53,12 @@ func serverMain(ctx context.Context, osArgs []string) error {
5353 }
5454 return err
5555 }
56- if runtime .GOOS != "windows" {
57- // stop signal handlers and register for stack trace handling, this is not supported for windows environments
58- signal .Stop (sigChan )
59- close (sigChan )
60- RegisterSignalHandler (ctx , flagStartupConfig .Logging .LogFilePath )
61- }
6256
6357 if * disablePersistentConfig {
6458 return legacyServerMain (ctx , osArgs , flagStartupConfig )
6559 }
6660
67- disablePersistentConfigFallback , err := serverMainPersistentConfig (ctx , fs , flagStartupConfig )
61+ disablePersistentConfigFallback , err := serverMainPersistentConfig (ctx , fs , flagStartupConfig , sigChan )
6862 if disablePersistentConfigFallback {
6963 return legacyServerMain (ctx , osArgs , flagStartupConfig )
7064 }
@@ -73,7 +67,7 @@ func serverMain(ctx context.Context, osArgs []string) error {
7367}
7468
7569// serverMainPersistentConfig runs the Sync Gateway server with persistent config.
76- func serverMainPersistentConfig (ctx context.Context , fs * flag.FlagSet , flagStartupConfig * StartupConfig ) (disablePersistentConfigFallback bool , err error ) {
70+ func serverMainPersistentConfig (ctx context.Context , fs * flag.FlagSet , flagStartupConfig * StartupConfig , sigChan chan os. Signal ) (disablePersistentConfigFallback bool , err error ) {
7771
7872 sc := DefaultStartupConfig (defaultLogFilePath )
7973 base .TracefCtx (ctx , base .KeyAll , "default config: %#v" , sc )
@@ -156,6 +150,14 @@ func serverMainPersistentConfig(ctx context.Context, fs *flag.FlagSet, flagStart
156150 return false , err
157151 }
158152
153+ if runtime .GOOS != "windows" {
154+ // stop signal handlers and register for stack trace handling to be able to log to configured directory,
155+ // this is not supported for windows environments
156+ signal .Stop (sigChan )
157+ close (sigChan )
158+ RegisterSignalHandler (ctx , svrctx .Config .Logging .LogFilePath )
159+ }
160+
159161 svrctx .initialStartupConfig = initialStartupConfig
160162
161163 svrctx .addLegacyPrincipals (ctx , legacyDbUsers , legacyDbRoles )
0 commit comments