basic version of forms

This commit is contained in:
metacryst
2025-12-22 04:53:00 -06:00
parent 80ceb48a62
commit 97bd02c59a
14 changed files with 153 additions and 1742 deletions

View File

@@ -7,28 +7,37 @@ import { fileURLToPath } from "url"
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const KERNEL = path.join(__dirname, "../kernel/kernel.js")
const PID_FILE = "/tmp/forms.pid"
const LOG_FILE = path.join(__dirname, "forms.log") // Define your log file
const cmd = process.argv[2]
// Function to append logs
function logToFile(message) {
fs.appendFileSync(LOG_FILE, `${new Date().toISOString()} - ${message}\n`)
}
if (cmd === "start") {
if (fs.existsSync(PID_FILE)) {
console.log("forms kernel already running")
logToFile("forms kernel already running")
process.exit(0)
}
const proc = spawn("node", [KERNEL], {
detached: true,
stdio: "ignore"
stdio: ["ignore", fs.openSync(LOG_FILE, "a"), fs.openSync(LOG_FILE, "a")] // Redirect stdout and stderr to the log file
})
proc.unref()
fs.writeFileSync(PID_FILE, String(proc.pid))
console.log("forms kernel started")
logToFile("forms kernel started")
}
if (cmd === "stop") {
if (!fs.existsSync(PID_FILE)) {
console.log("forms kernel not running")
logToFile("forms kernel not running")
process.exit(0)
}
@@ -36,8 +45,10 @@ if (cmd === "stop") {
process.kill(pid)
fs.unlinkSync(PID_FILE)
console.log("forms kernel stopped")
logToFile("forms kernel stopped")
}
if (!cmd) {
console.log("usage: forms start | stop")
logToFile("usage: forms start | stop")
}