TODO: Pass ctx down into HTTP servers so that serverMain can be stopped.
(ctx context.Context, osArgs []string)
| 39 | |
| 40 | // TODO: Pass ctx down into HTTP servers so that serverMain can be stopped. |
| 41 | func serverMain(ctx context.Context, osArgs []string) error { |
| 42 | sigChan := RegisterSignalHandler(ctx, "") |
| 43 | defer base.FatalPanicHandler() |
| 44 | |
| 45 | base.InitializeMemoryLoggers() |
| 46 | base.LogSyncGatewayVersion(ctx) |
| 47 | |
| 48 | flagStartupConfig, fs, disablePersistentConfig, err := parseFlags(ctx, osArgs) |
| 49 | if err != nil { |
| 50 | // Return nil for ErrHelp so the shell exit code is 0 |
| 51 | if err == flag.ErrHelp { |
| 52 | return nil |
| 53 | } |
| 54 | return err |
| 55 | } |
| 56 | |
| 57 | if *disablePersistentConfig { |
| 58 | return legacyServerMain(ctx, osArgs, flagStartupConfig) |
| 59 | } |
| 60 | |
| 61 | disablePersistentConfigFallback, err := serverMainPersistentConfig(ctx, fs, flagStartupConfig, sigChan) |
| 62 | if disablePersistentConfigFallback { |
| 63 | return legacyServerMain(ctx, osArgs, flagStartupConfig) |
| 64 | } |
| 65 | |
| 66 | return err |
| 67 | } |
| 68 | |
| 69 | // serverMainPersistentConfig runs the Sync Gateway server with persistent config. |
| 70 | func serverMainPersistentConfig(ctx context.Context, fs *flag.FlagSet, flagStartupConfig *StartupConfig, sigChan chan os.Signal) (disablePersistentConfigFallback bool, err error) { |
no test coverage detected