bin/gua.ts: init, for creating systemd services
This commit is contained in:
23
src/bin/gua.ts
Normal file
23
src/bin/gua.ts
Normal 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}`))
|
||||
Reference in New Issue
Block a user