@irsyadulibad/servermon 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli/service.ts +7 -20
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@irsyadulibad/servermon",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Lightweight server monitoring daemon — collects system metrics and sends structured reports to Telegram. Built with Bun + TypeScript.",
5
5
  "module": "index.ts",
6
6
  "type": "module",
@@ -1,5 +1,5 @@
1
1
  import type { Crust } from "@crustjs/core";
2
- import { loadConfig, configPath } from "../config";
2
+ import { listServers, configPath } from "../config";
3
3
 
4
4
  const HOME = process.env.HOME ?? "~";
5
5
  const SYSTEMD_DIR = `${HOME}/.config/systemd/user`;
@@ -54,9 +54,9 @@ function getServiceStatus(): string {
54
54
  /* ------------------------------------------------------------------ */
55
55
 
56
56
  async function cmdInstall(): Promise<void> {
57
- const config = await loadConfig();
58
- if (!config) {
59
- console.error("❌ No config found. Run `servermon setup` first.");
57
+ const servers = await listServers();
58
+ if (servers.length === 0) {
59
+ console.error("❌ No servers configured. Run `servermon setup` or `servermon setup --name <name>` first.");
60
60
  process.exit(1);
61
61
  }
62
62
 
@@ -74,25 +74,12 @@ async function cmdInstall(): Promise<void> {
74
74
 
75
75
  console.log(`🔍 bun: ${bunPath}`);
76
76
  console.log(`🔍 servermon: ${servermonPath}`);
77
- console.log(`📁 Config: ${configPath()}\n`);
77
+ console.log(`📁 Config: ${configPath()}`);
78
+ console.log(`📋 Servers: ${servers.join(", ")}\n`);
78
79
 
79
80
  await ensureSystemdDir();
80
81
 
81
- const serviceContent = `[Unit]
82
- Description=Server Monitor — Telegram system health reports
83
- After=network-online.target
84
- Wants=network-online.target
85
-
86
- [Service]
87
- Type=simple
88
- ExecStart=${servermonPath} start
89
- Restart=always
90
- RestartSec=30
91
- Environment=NODE_ENV=production
92
-
93
- [Install]
94
- WantedBy=default.target
95
- `;
82
+ const serviceContent = `[Unit]\nDescription=Server Monitor — Telegram system health reports\nAfter=network-online.target\nWants=network-online.target\n\n[Service]\nType=simple\nExecStart=${servermonPath} start\nRestart=always\nRestartSec=30\nEnvironment=NODE_ENV=production\n\n[Install]\nWantedBy=default.target\n`;
96
83
 
97
84
  await Bun.write(SERVICE_PATH, serviceContent);
98
85
  console.log(`📄 Written: ${SERVICE_PATH}`);