Bootstrap provides startup logic in a real environment
(centralPath, nodePath, logPath string, verbose bool, opts state.NylonOptions)
| 102 | |
| 103 | // Bootstrap provides startup logic in a real environment |
| 104 | func Bootstrap(centralPath, nodePath, logPath string, verbose bool, opts state.NylonOptions) { |
| 105 | setupDebugging(opts) |
| 106 | level := slog.LevelInfo |
| 107 | if verbose { |
| 108 | level = slog.LevelDebug |
| 109 | } |
| 110 | |
| 111 | tunables := state.DefaultRouterTunables() |
| 112 | centralCfg, err := readCentralConfig(centralPath, nodePath, &tunables) |
| 113 | if err != nil { |
| 114 | fatal("failed to read central config", err) |
| 115 | } |
| 116 | nodeCfg, err := readNodeConfig(nodePath) |
| 117 | if err != nil { |
| 118 | fatal("failed to read node config", err) |
| 119 | } |
| 120 | if logPath != "" { |
| 121 | nodeCfg.LogPath = logPath |
| 122 | } |
| 123 | |
| 124 | state.ExpandCentralConfig(centralCfg) |
| 125 | if err = state.CentralConfigValidator(centralCfg); err != nil { |
| 126 | fatal("invalid central config", err) |
| 127 | } |
| 128 | if err = state.NodeConfigValidator(centralCfg, nodeCfg); err != nil { |
| 129 | fatal("invalid node config", err) |
| 130 | } |
| 131 | n, err := NewNylon(*centralCfg, *nodeCfg, level, centralPath, nil, opts, nil) |
| 132 | if err != nil { |
| 133 | fatal("failed to initialize nylon", err) |
| 134 | } |
| 135 | if err = n.Start(); err != nil { |
| 136 | fatal("nylon exited with error", err) |
| 137 | } |
| 138 | } |
no test coverage detected