make sync command configurable via appsettings

This commit is contained in:
Meleki committed 2026-02-21 11:40:39 +01:00
1 parent dbaad6b372
commit bc9944c5f2
2 files changed
+10 -4

No files matched your search

+6 -3
View File
@@ -213,12 +213,15 @@ app.MapGet("/api/entry-chains", (Func<SqliteConnection> factory, string from, st
// POST /api/sync - run export.mjs to import new entries
app.MapPost("/api/sync", async () =>
{
var wd = "/home/node/.openclaw/workspace/projects/token-analytics/jsonl-sync";
var psi = new System.Diagnostics.ProcessStartInfo("docker", $"exec meleki node {wd}/export.mjs")
var config = app.Configuration;
var wd = config["SyncWorkingDirectory"] ?? "/opt/token-analytics/jsonl-sync";
var fileName = config["SyncCommandFileName"] ?? "node";
var arguments = config["SyncCommandArguments"] ?? "/opt/token-analytics/jsonl-sync/export.mjs";
var psi = new System.Diagnostics.ProcessStartInfo(fileName, arguments)
{
RedirectStandardOutput = true,
RedirectStandardError = true,
WorkingDirectory = wd!
WorkingDirectory = wd
};
var proc = System.Diagnostics.Process.Start(psi)!;
var stdout = await proc.StandardOutput.ReadToEndAsync();