MCPcopy Create free account
hub / github.com/agent-tower/core / startServer

Function startServer

packages/server/scripts/dev.mjs:135–176  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

133 }
134}
135
136function startServer() {
137 if (shuttingDown) {
138 return;
139 }
140
141 const childProcess = spawn(process.execPath, ['--import', 'tsx', entryFile], {
142 cwd: packageRoot,
143 stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
144 env: process.env,
145 });
146
147 child = childProcess;
148
149 childProcess.on('exit', (code, signal) => {
150 if (child !== childProcess) {
151 return;
152 }
153
154 child = null;
155
156 if (shuttingDown) {
157 return;
158 }
159
160 if (restartAfterExit) {
161 restartAfterExit = false;
162 setTimeout(() => {
163 if (!shuttingDown && !child) {
164 startServer();
165 restartInProgress = false;
166 }
167 }, restartDelayMs);
168 return;
169 }
170
171 restartInProgress = false;
172
173 if (code && code !== 0) {
174 log(`server exited with code ${code}. Waiting for changes...`);
175 }
176 });
177}
178
179function restartServer(changedPath) {

Callers 2

restartServerFunction · 0.85
dev.mjsFile · 0.85

Calls 3

spawnFunction · 0.85
logFunction · 0.70
onMethod · 0.45

Tested by

no test coverage detected