Added ldc2 deployment script, upgraded Handy-httpd and scheduled.
This commit is contained in:
parent
c833571bbc
commit
1c59ed5bb6
|
@ -1,2 +1,3 @@
|
|||
# create-schematic-gen-site
|
||||
|
||||
Simple HTTP server for generating schematics, used with my Materials-Extractor program.
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
dub clean
|
||||
rm -f create-schematic-gen-site
|
||||
dub build --compiler=/opt/ldc2/ldc2-1.33.0-linux-x86_64/bin/ldc2 --build=release --force
|
||||
echo "Stopping CSGS service."
|
||||
ssh -f root@andrewlalis.com 'systemctl stop csgs'
|
||||
echo "Uploading new binary."
|
||||
scp create-schematic-gen-site root@andrewlalis.com:/opt/create-schematic-gen-site/
|
||||
echo "Starting CSGS service."
|
||||
ssh -f root@andrewlalis.com 'systemctl start csgs'
|
2
dub.json
2
dub.json
|
@ -4,7 +4,7 @@
|
|||
],
|
||||
"copyright": "Copyright © 2023, Andrew Lalis",
|
||||
"dependencies": {
|
||||
"handy-httpd": "~>7.6.4",
|
||||
"handy-httpd": "~>7.7.0",
|
||||
"requests": "~>2.1.1",
|
||||
"scheduled": "~>1.2.0",
|
||||
"slf4d": "~>2.4.2"
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
"automem": "0.6.9",
|
||||
"cachetools": "0.4.1",
|
||||
"cronexp": "0.1.0-beta3",
|
||||
"handy-httpd": "7.6.4",
|
||||
"handy-httpd": "7.7.0",
|
||||
"httparsed": "1.2.1",
|
||||
"requests": "2.1.1",
|
||||
"scheduled": "1.1.0",
|
||||
"scheduled": "1.2.0",
|
||||
"slf4d": "2.4.2",
|
||||
"streams": "3.5.0",
|
||||
"test_allocator": "0.3.4",
|
||||
|
|
|
@ -15,10 +15,11 @@ void startServer() {
|
|||
config.port = 8100;
|
||||
|
||||
PathDelegatingHandler handler = new PathDelegatingHandler();
|
||||
handler.addMapping("POST", "/extracts", &handleExtract);
|
||||
handler.addMapping("GET", "/extracts/{extractId}", &getExtract);
|
||||
handler.addMapping("POST", "/item-reports", &handleItemReport);
|
||||
handler.addMapping("GET", "/status", (ref HttpRequestContext ctx) {
|
||||
handler.addMapping(Method.GET, "/extracts", &handleExtract);
|
||||
handler.addMapping(Method.GET, "/extracts/{extractId}", &getExtract);
|
||||
handler.addMapping(Method.POST, "/item-reports", &handleItemReport);
|
||||
handler.addMapping(Method.GET, "/item-reports", &getItemReports);
|
||||
handler.addMapping(Method.GET, "/status", (ref HttpRequestContext ctx) {
|
||||
ctx.response.setStatus(HttpStatus.OK);
|
||||
ctx.response.writeBodyString("online");
|
||||
});
|
||||
|
@ -34,7 +35,7 @@ private void handleExtract(ref HttpRequestContext ctx) {
|
|||
MultipartFormData data = ctx.request.readBodyAsMultipartFormData();
|
||||
if (!validateExtractRequest(data, ctx.response)) return;
|
||||
string extractId = doExtract(data);
|
||||
JSONValue result = JSONValue.emptyObject;
|
||||
JSONValue result = JSONValue(string[string].init);
|
||||
result.object["extractId"] = JSONValue(extractId);
|
||||
ctx.response.writeBodyString(result.toJSON(), "application/json");
|
||||
}
|
||||
|
@ -54,3 +55,8 @@ private void handleItemReport(ref HttpRequestContext ctx) {
|
|||
f.writeln(itemName);
|
||||
f.close();
|
||||
}
|
||||
|
||||
private void getItemReports(ref HttpRequestContext ctx) {
|
||||
import handy_httpd.components.responses : fileResponse;
|
||||
fileResponse(ctx.response, "item-reports.txt", "text/plain");
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ module csgs.task;
|
|||
|
||||
import slf4d;
|
||||
import scheduled;
|
||||
import scheduled.taskpool_scheduler;
|
||||
|
||||
import std.datetime;
|
||||
import std.typecons;
|
||||
|
@ -13,11 +14,14 @@ import std.stdio;
|
|||
import csgs.extract;
|
||||
|
||||
void startScheduledTasks() {
|
||||
JobScheduler scheduler = new ThreadedJobScheduler();
|
||||
JobScheduler scheduler = new TaskPoolScheduler();
|
||||
|
||||
Job cleanJob = new FunctionJob(&cleanOldExtracts);
|
||||
scheduler.addJob(cleanJob, new FixedIntervalSchedule(days(1)));
|
||||
|
||||
Job updateCheckJob = new FunctionJob(&checkForExtractorUpdate);
|
||||
scheduler.addJob(updateCheckJob, new FixedIntervalSchedule(hours(1)));
|
||||
|
||||
scheduler.start();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue