mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-09-16 00:21:52 +08:00
WIP
This commit is contained in:
59
extra/cli.js
59
extra/cli.js
@@ -1,5 +1,8 @@
|
||||
#!/usr/bin/env node
|
||||
const path = require("path");
|
||||
const args = require("args-parser")(process.argv);
|
||||
|
||||
// Set the data directory
|
||||
if (!process.env.DATA_DIR) {
|
||||
if (process.platform === "win32") {
|
||||
process.env.DATA_DIR = process.env.LOCALAPPDATA + "\\uptime-kuma\\";
|
||||
@@ -15,4 +18,58 @@ if (!process.env.DATA_DIR) {
|
||||
}
|
||||
}
|
||||
|
||||
require("../server/server");
|
||||
// Change the working directory to the root of the project, so it can read the dist folder
|
||||
process.chdir(path.join(__dirname, ".."));
|
||||
|
||||
if (args.run) {
|
||||
require("../server/server");
|
||||
|
||||
} else if (args.installService) {
|
||||
|
||||
if (process.platform === "win32") {
|
||||
let Service = require("node-windows").Service;
|
||||
|
||||
// Create a new service object
|
||||
let svc = new Service({
|
||||
name: "Uptime Kuma",
|
||||
description: "Uptime Kuma is an easy-to-use self-hosted monitoring tool.",
|
||||
script: "C:\\path\\to\\helloworld.js",
|
||||
nodeOptions: [
|
||||
"--harmony",
|
||||
"--max_old_space_size=4096"
|
||||
]
|
||||
//, workingDirectory: '...'
|
||||
//, allowServiceLogon: true
|
||||
});
|
||||
|
||||
// Listen for the "install" event, which indicates the
|
||||
// process is available as a service.
|
||||
svc.on("install", function () {
|
||||
svc.start();
|
||||
});
|
||||
|
||||
svc.install();
|
||||
} else if (process.platform === "linux") {
|
||||
|
||||
} else {
|
||||
console.error("Unable to install service on platform: " + process.platform);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
} else if (args.version || args.v) {
|
||||
const version = require("../package.json").version;
|
||||
console.log("Uptime Kuma version: " + version);
|
||||
|
||||
} else {
|
||||
console.log(`Usage: uptime-kuma [options]
|
||||
|
||||
Options:
|
||||
--install-service Install Uptime Kuma service (Windows and Linux only)
|
||||
--uninstall-service Uninstall Uptime Kuma service
|
||||
--run Run Uptime Kuma directly in the terminal
|
||||
--data-dir="your path" Set the data directory
|
||||
--version Print the version
|
||||
--help Print this help
|
||||
`);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user