From f84757ec9036a1e8947ae22c8d871b60318b767a Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Fri, 18 Apr 2025 09:34:59 +0800 Subject: [PATCH] bin/gua.ts: init, for creating systemd services --- src/bin/gua.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/bin/gua.ts diff --git a/src/bin/gua.ts b/src/bin/gua.ts new file mode 100644 index 0000000..6184308 --- /dev/null +++ b/src/bin/gua.ts @@ -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}`)) \ No newline at end of file