From c7941d027be068f6e563a17e882232580fe15334 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 5 Sep 2025 20:12:41 +0900 Subject: feat(worker): move directory worker/ to worker/php/ --- worker/index.mjs | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 worker/index.mjs (limited to 'worker/index.mjs') diff --git a/worker/index.mjs b/worker/index.mjs deleted file mode 100644 index 9950ffa..0000000 --- a/worker/index.mjs +++ /dev/null @@ -1,39 +0,0 @@ -import { fork } from "node:child_process"; -import { serve } from "@hono/node-server"; -import { Hono } from "hono"; - -const execPhp = (code, input, timeoutMsec) => { - return new Promise((resolve, _reject) => { - const proc = fork("./exec.mjs"); - - proc.send({ code, input }); - - proc.on("message", (result) => { - resolve(result); - proc.kill(); - }); - - setTimeout(() => { - resolve({ - status: "timeout", - stdout: "", - stderr: `Time Limit Exceeded: ${timeoutMsec} msec`, - }); - proc.kill(); - }, timeoutMsec); - }); -}; - -const app = new Hono(); - -app.post("/exec", async (c) => { - console.log("worker/exec"); - const { code, stdin, max_duration_ms } = await c.req.json(); - const result = await execPhp(code, stdin, max_duration_ms); - return c.json(result); -}); - -serve({ - fetch: app.fetch, - port: 80, -}); -- cgit v1.3.1