@xeplr/monitor 1.0.0 → 1.0.1
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.
- package/README.md +1 -1
- package/deploy/install.sh +18 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -120,7 +120,7 @@ npx -y @xeplr/monitor
|
|
|
120
120
|
|
|
121
121
|
There is no remote deploy: the installer installs the machine it runs on, from the copy npx fetched, and fetches nothing else. From a checkout of this repository, `npm install && node deploy/deploy.js` does the same with that checkout.
|
|
122
122
|
|
|
123
|
-
What the server needs first: Linux with systemd and D-Bus, Node.js 20+ and npm, Postgres and Redis (on it or reachable from it), and nginx + certbot for a web address. The installer runs `deploy/install.sh` as root: run it as root, or `sudo` asks its password once — before any question, so the install never stops for it.
|
|
123
|
+
What the server needs first: Linux with systemd and D-Bus, Node.js 20+ and npm **installed system-wide** (`/usr/bin` or `/usr/local/bin`, e.g. NodeSource's package — the services run as their own `xeplr-monitor` user, which cannot run a Node from someone's home folder such as nvm's; the installer uses the system one and stops before changing anything when there is none), Postgres and Redis (on it or reachable from it), and nginx + certbot for a web address. The installer runs `deploy/install.sh` as root: run it as root, or `sudo` asks its password once — before any question, so the install never stops for it.
|
|
124
124
|
|
|
125
125
|
It asks for what it needs as it goes and stores nothing but the app's own settings file:
|
|
126
126
|
|
package/deploy/install.sh
CHANGED
|
@@ -73,6 +73,22 @@ fi
|
|
|
73
73
|
# ── its own user, which reads the journal ────────────────────────────────
|
|
74
74
|
id "$USER_NAME" >/dev/null 2>&1 || { useradd -r -m -d "$VAR" -s /usr/sbin/nologin "$USER_NAME"; say "User $USER_NAME made"; }
|
|
75
75
|
usermod -aG systemd-journal "$USER_NAME"
|
|
76
|
+
|
|
77
|
+
# ── the Node its services run on: one THEIR user can run ─────────────────
|
|
78
|
+
# The services run as $USER_NAME, not as whoever runs this. A Node from nvm
|
|
79
|
+
# lives in that person's home (/root/.nvm/…), which $USER_NAME cannot enter:
|
|
80
|
+
# systemd then fails every start with "Permission denied" (status 203/EXEC).
|
|
81
|
+
# So the Node found above is used only if $USER_NAME can run it; else the
|
|
82
|
+
# server's own (/usr/bin, /usr/local/bin). Checked before anything changes,
|
|
83
|
+
# so a refusal leaves the running install as it was.
|
|
84
|
+
SERVICE_NODE=""
|
|
85
|
+
for candidate in "$NODE" /usr/bin/node /usr/local/bin/node; do
|
|
86
|
+
[ -x "$candidate" ] || continue
|
|
87
|
+
major=$(sudo -u "$USER_NAME" "$candidate" -p 'process.versions.node.split(".")[0]' 2>/dev/null || true)
|
|
88
|
+
if [ -n "$major" ] && [ "$major" -ge 20 ]; then SERVICE_NODE=$candidate; break; fi
|
|
89
|
+
done
|
|
90
|
+
[ -n "$SERVICE_NODE" ] || stop "the monitor's services run as $USER_NAME, which cannot run Node.js at $NODE (in a home folder, e.g. from nvm) and there is no Node.js 20+ at /usr/bin or /usr/local/bin. Install Node.js system-wide (e.g. NodeSource's package), then run this again — the running install was not changed"
|
|
91
|
+
[ "$SERVICE_NODE" = "$NODE" ] || say "Services run on $SERVICE_NODE ($NODE is in a home folder $USER_NAME cannot enter)"
|
|
76
92
|
mkdir -p "$VAR/logs" "$VAR/data" "$SHARED" "$APP/releases"
|
|
77
93
|
chown -R "$USER_NAME:$USER_NAME" "$VAR" && chmod 750 "$VAR"
|
|
78
94
|
|
|
@@ -168,10 +184,10 @@ UNIT
|
|
|
168
184
|
}
|
|
169
185
|
# Restart=always is also how settings take effect: the setup page and App
|
|
170
186
|
# settings exit 75 after writing $ENV_FILE, and systemd starts them again.
|
|
171
|
-
unit xeplr-monitor-auth "xeplr-monitor: sign-in (@xeplr/auth)" "$
|
|
187
|
+
unit xeplr-monitor-auth "xeplr-monitor: sign-in (@xeplr/auth)" "$SERVICE_NODE $APP/current/api/bin/auth.js" ""
|
|
172
188
|
# The API controls services: the journal group reads their logs; sudo needs
|
|
173
189
|
# to gain privileges, so NoNewPrivileges stays off — sudoers is the limit.
|
|
174
|
-
unit xeplr-monitor-api "xeplr-monitor: the API (services, logs, start/stop)" "$
|
|
190
|
+
unit xeplr-monitor-api "xeplr-monitor: the API (services, logs, start/stop)" "$SERVICE_NODE $APP/current/api/bin/www" "SupplementaryGroups=systemd-journal"
|
|
175
191
|
systemctl daemon-reload
|
|
176
192
|
systemctl enable xeplr-monitor-auth xeplr-monitor-api >/dev/null 2>&1
|
|
177
193
|
systemctl restart xeplr-monitor-auth xeplr-monitor-api
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xeplr/monitor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "See a server and control its systemd services from a web page: how each is doing, start / stop / restart / kill, live logs, memory, CPU, requests and errors over time, database backups to S3. A xeplr app: run `npx @xeplr/monitor` on the server to install it there.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|