bin/gua.ts: init, for creating systemd services

This commit is contained in:
2025-04-18 09:34:59 +08:00
parent 64bcd0915e
commit f84757ec90

23
src/bin/gua.ts Normal file
View File

@@ -0,0 +1,23 @@
import { spawn } from "child_process";
import { systemdRunOptions } from "../commands/systemd.js";
import path from "path";
import { randomUUID } from "crypto";
import chalk from "chalk";
const uuid = randomUUID()
spawn("systemd-run",
[
`--working-directory=${path.resolve(process.cwd())}`,
...systemdRunOptions({
user: true,
unit: uuid,
}),
...process.argv.slice(2),
]
)
console.log(`Service started as ID: ${uuid}, command suggest:`)
console.log(chalk.red(` systemctl --user status ${uuid}`))
console.log(chalk.red(` journalctl --user -xeu ${uuid}`))