Compare commits
No commits in common. "37141e87f66e3ab179018f33a7f02829dbe37d63" and "b9adb6f854d496da12e5591a356455e5b2aed573" have entirely different histories.
37141e87f6
...
b9adb6f854
|
@ -210,27 +210,20 @@ router.ws('/connect', async (ws, req) => {
|
|||
if (job === null) {
|
||||
job = await get_job(msg);
|
||||
|
||||
try {
|
||||
await job.prime();
|
||||
await job.prime();
|
||||
|
||||
ws.send(
|
||||
JSON.stringify({
|
||||
type: 'runtime',
|
||||
language: job.runtime.language,
|
||||
version: job.runtime.version.raw,
|
||||
})
|
||||
);
|
||||
ws.send(
|
||||
JSON.stringify({
|
||||
type: 'runtime',
|
||||
language: job.runtime.language,
|
||||
version: job.runtime.version.raw,
|
||||
})
|
||||
);
|
||||
|
||||
await job.execute(event_bus);
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`Error cleaning up job: ${job.uuid}:\n${error}`
|
||||
);
|
||||
throw error;
|
||||
} finally {
|
||||
await job.cleanup();
|
||||
}
|
||||
ws.close(4999, 'Job Completed'); // Will not execute if an error is thrown above
|
||||
await job.execute(event_bus);
|
||||
await job.cleanup();
|
||||
|
||||
ws.close(4999, 'Job Completed');
|
||||
} else {
|
||||
ws.close(4000, 'Already Initialized');
|
||||
}
|
||||
|
@ -272,13 +265,9 @@ router.ws('/connect', async (ws, req) => {
|
|||
});
|
||||
|
||||
router.post('/execute', async (req, res) => {
|
||||
let job;
|
||||
try {
|
||||
job = await get_job(req.body);
|
||||
} catch (error) {
|
||||
return res.status(400).json(error);
|
||||
}
|
||||
try {
|
||||
const job = await get_job(req.body);
|
||||
|
||||
await job.prime();
|
||||
|
||||
let result = await job.execute();
|
||||
|
@ -287,17 +276,11 @@ router.post('/execute', async (req, res) => {
|
|||
result.run = result.compile;
|
||||
}
|
||||
|
||||
await job.cleanup();
|
||||
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
logger.error(`Error executing job: ${job.uuid}:\n${error}`);
|
||||
return res.status(500).send();
|
||||
} finally {
|
||||
try {
|
||||
await job.cleanup(); // This gets executed before the returns in try/catch
|
||||
} catch (error) {
|
||||
logger.error(`Error cleaning up job: ${job.uuid}:\n${error}`);
|
||||
return res.status(500).send(); // On error, this replaces the return in the outer try-catch
|
||||
}
|
||||
return res.status(400).json(error);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -35,10 +35,7 @@ expressWs(app);
|
|||
}
|
||||
}
|
||||
});
|
||||
fss.chmodSync(
|
||||
path.join(config.data_directory, globals.data_directories.jobs),
|
||||
0o711
|
||||
);
|
||||
fss.chmodSync(path.join(config.data_directory, globals.data_directories.jobs), 0o711)
|
||||
|
||||
logger.info('Loading packages');
|
||||
const pkgdir = path.join(
|
||||
|
@ -95,12 +92,7 @@ expressWs(app);
|
|||
logger.debug('Calling app.listen');
|
||||
const [address, port] = config.bind_address.split(':');
|
||||
|
||||
const server = app.listen(port, address, () => {
|
||||
app.listen(port, address, () => {
|
||||
logger.info('API server started on', config.bind_address);
|
||||
});
|
||||
|
||||
process.on('SIGTERM', () => {
|
||||
server.close();
|
||||
process.exit(0)
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -14,7 +14,7 @@ RUN apt-get update && apt-get install -y unzip autoconf build-essential libssl-d
|
|||
rm -rf /var/lib/apt/lists/* && \
|
||||
update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2
|
||||
|
||||
ADD entrypoint.sh mkindex.sh serve.py /
|
||||
ADD entrypoint.sh mkindex.sh /
|
||||
|
||||
ENTRYPOINT ["bash","/entrypoint.sh"]
|
||||
CMD ["--no-build"]
|
||||
|
|
|
@ -27,7 +27,7 @@ do
|
|||
echo "Done with package $pkg"
|
||||
elif [[ $CI -eq 1 ]]; then
|
||||
echo "Commit SHA: $pkg"
|
||||
|
||||
|
||||
cd ..
|
||||
echo "Changed files:"
|
||||
git diff --name-only $pkg^1 $pkg
|
||||
|
@ -52,9 +52,8 @@ echo "Index created"
|
|||
|
||||
if [[ $SERVER -eq 1 ]]; then
|
||||
echo "Starting index server.."
|
||||
# We want the child process to replace the shell to handle signals
|
||||
exec python3 /serve.py
|
||||
python3 -m http.server
|
||||
else
|
||||
echo "Skipping starting index server"
|
||||
fi
|
||||
exit 0
|
||||
exit 0
|
|
@ -1,18 +0,0 @@
|
|||
import signal
|
||||
import sys
|
||||
import http.server
|
||||
import socketserver
|
||||
|
||||
PORT = 8000
|
||||
|
||||
Handler = http.server.SimpleHTTPRequestHandler
|
||||
|
||||
|
||||
def signal_handler(sig, frame):
|
||||
sys.exit(0)
|
||||
|
||||
signal.signal(signal.SIGTERM, signal_handler)
|
||||
|
||||
with socketserver.TCPServer(("", PORT), Handler) as httpd:
|
||||
print("serving at port", PORT)
|
||||
httpd.serve_forever()
|
Loading…
Reference in New Issue