@xeplr/monitor 0.1.3 → 1.0.0

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 (67) hide show
  1. package/README.md +138 -125
  2. package/api/README.md +71 -0
  3. package/api/app.js +46 -0
  4. package/api/bin/auth.js +37 -0
  5. package/api/bin/www +72 -0
  6. package/api/db/setup.js +10 -0
  7. package/api/env.required.js +37 -0
  8. package/api/lib/host.js +188 -0
  9. package/api/lib/jobs.js +83 -0
  10. package/api/lib/services.js +67 -0
  11. package/api/lib/stats.js +362 -0
  12. package/{lib → api/lib}/systemd.js +75 -14
  13. package/api/migrations/0001_monitor.sql +43 -0
  14. package/api/migrations/0002_backup_connections.sql +26 -0
  15. package/api/migrations/0003_settings_audit.sql +18 -0
  16. package/api/migrations/0004_monitor_stats.sql +73 -0
  17. package/api/migrations/README.md +9 -0
  18. package/api/migrations-auth/0006_monitor.sql +56 -0
  19. package/api/migrations-auth/0007_monitor_home.sql +42 -0
  20. package/api/migrations-auth/0008_backups.sql +44 -0
  21. package/api/migrations-auth/0009_app_settings.sql +44 -0
  22. package/api/migrations-auth/0010_monitor_history.sql +22 -0
  23. package/api/models/index.js +18 -0
  24. package/api/package-lock.json +2839 -0
  25. package/api/package.json +39 -0
  26. package/api/production.env.example +61 -0
  27. package/api/routes/appSettings.js +73 -0
  28. package/api/routes/index.js +47 -0
  29. package/api/routes/monitor.js +196 -0
  30. package/api/setup.schema.js +166 -0
  31. package/deploy/control.sh +27 -0
  32. package/deploy/deploy.js +183 -0
  33. package/deploy/install.sh +177 -77
  34. package/deploy/settings.cjs +93 -0
  35. package/package.json +28 -47
  36. package/ui/.env +8 -0
  37. package/ui/README.md +29 -0
  38. package/ui/index.html +13 -0
  39. package/ui/package-lock.json +2094 -0
  40. package/ui/package.json +31 -0
  41. package/ui/pages.json +33 -0
  42. package/ui/public/logo-wide.svg +17 -0
  43. package/ui/public/logo.svg +10 -0
  44. package/ui/src/App.jsx +130 -0
  45. package/ui/src/api/monitor.js +6 -0
  46. package/ui/src/index.css +414 -0
  47. package/ui/src/main.jsx +27 -0
  48. package/ui/src/pages/Connections.jsx +9 -0
  49. package/ui/src/pages/Home.jsx +8 -0
  50. package/ui/src/pages/Monitor.jsx +9 -0
  51. package/ui/vite.config.js +56 -0
  52. package/bin/deploy.js +0 -181
  53. package/bin/server.js +0 -19
  54. package/bin/users.js +0 -86
  55. package/deploy/monitor.env.example +0 -16
  56. package/deploy/nginx.conf.example +0 -18
  57. package/deploy/sudoers.example +0 -13
  58. package/deploy/xeplr-monitor.service +0 -26
  59. package/index.js +0 -89
  60. package/lib/router.js +0 -179
  61. package/lib/services.js +0 -76
  62. package/lib/session.js +0 -78
  63. package/lib/store.js +0 -73
  64. package/lib/users.js +0 -119
  65. package/public/assets/index-BsBYpvNI.js +0 -18
  66. package/public/assets/index-DNZBwVTn.css +0 -1
  67. package/public/index.html +0 -15
package/package.json CHANGED
@@ -1,64 +1,45 @@
1
1
  {
2
2
  "name": "@xeplr/monitor",
3
- "version": "0.1.3",
4
- "description": "See and control a server's services: status, start, stop, restart, kill, and their logs live. Its own sign-in, no database",
5
- "main": "index.js",
6
- "files": [
7
- "index.js",
8
- "lib/",
9
- "bin/",
10
- "deploy/",
11
- "public/"
12
- ],
13
- "bin": {
14
- "xeplr-monitor-server": "./bin/server.js",
15
- "xeplr-monitor-users": "./bin/users.js",
16
- "xeplr-monitor-deploy": "./bin/deploy.js"
17
- },
18
- "exports": {
19
- ".": "./index.js",
20
- "./package.json": "./package.json"
3
+ "version": "1.0.0",
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
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/Xeplr/xeplr-monitor"
21
9
  },
10
+ "homepage": "https://github.com/Xeplr/xeplr-monitor#readme",
22
11
  "keywords": [
23
12
  "monitor",
24
13
  "systemd",
25
- "journalctl",
14
+ "server",
26
15
  "logs",
27
- "restart",
28
- "ops"
16
+ "xeplr"
29
17
  ],
30
- "author": "xeplr",
31
- "license": "MIT",
32
- "repository": {
33
- "type": "git",
34
- "url": "https://github.com/Xeplr/xeplr-monitor"
18
+ "bin": {
19
+ "xeplr-monitor": "deploy/deploy.js"
35
20
  },
21
+ "files": [
22
+ "deploy/",
23
+ "api/",
24
+ "ui/",
25
+ "!api/test/",
26
+ "!api/*.env",
27
+ "!api/logs/",
28
+ "!ui/dist/",
29
+ "README.md",
30
+ "LICENSE"
31
+ ],
36
32
  "publishConfig": {
37
33
  "access": "public"
38
34
  },
39
- "engines": {
40
- "node": ">=20"
35
+ "scripts": {
36
+ "install-here": "node deploy/deploy.js",
37
+ "test": "npm --prefix api test"
41
38
  },
42
39
  "dependencies": {
43
- "@xeplr/base-apis": "^3.0.3",
44
- "@xeplr/utils": "^2.0.1",
45
- "express": "^5.3.0"
46
- },
47
- "scripts": {
48
- "test": "node --test test/*.test.js",
49
- "build": "vite build --config ui/vite.config.js",
50
- "dev:page": "vite --config ui/vite.config.js",
51
- "prepack": "npm run build"
40
+ "@xeplr/cli": "^0.3.8"
52
41
  },
53
- "devDependencies": {
54
- "@tanstack/react-table": "^8.21.3",
55
- "@vitejs/plugin-react": "^5.2.0",
56
- "@xeplr/ui-monitor": "^0.1.1",
57
- "@xeplr/ui-table": "^1.1.3",
58
- "@xeplr/ui-utils": "^1.1.8",
59
- "react": "^19.3.1",
60
- "react-dom": "^19.3.1",
61
- "react-router-dom": "^7.18.5",
62
- "vite": "^7.3.7"
42
+ "engines": {
43
+ "node": ">=20"
63
44
  }
64
45
  }
package/ui/.env ADDED
@@ -0,0 +1,8 @@
1
+ # xeplr-monitor UI — dev port and the services it talks to.
2
+ #
3
+ # Read by vite.config.js, so no port is written in code. Change a number here
4
+ # and the dev server and every proxy target follow.
5
+
6
+ UI_PORT=19400
7
+ AUTH_URL=http://localhost:19401
8
+ API_URL=http://localhost:19402
package/ui/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # xeplr-monitor — ui
2
+
3
+ The React app (Vite): `@xeplr/ui-account` for sign-in and the app shell, and the Home and Monitor pages from `@xeplr/ui-monitor` (`ServerPage`, `MonitorPage`).
4
+
5
+ ```bash
6
+ npm run dev # http://localhost:19400
7
+ npm run build # → dist/
8
+ ```
9
+
10
+ `.env` holds the port and where the sign-in service and the API are; `vite.config.js` proxies `/auth/api` to sign-in and `/api` (and `/health`, `/whoami`) to the API. In production nginx does the same (the deploy writes it).
11
+
12
+ ## Layout
13
+
14
+ | Path | What |
15
+ |---|---|
16
+ | `src/main.jsx` | `ThemeProvider` (required — the theme's colours exist only inside it) and `AccessProvider` |
17
+ | `src/App.jsx` | routes (`/` opens Home), the side rail (`drawerItems`: Home, Monitor) and the settings menu (Admin, App settings) — **by key**, never by label |
18
+ | `/settings/app` (in `src/App.jsx`) | **App settings** — `@xeplr/ui-setup`'s `AppSettingsPage` on `/api/app-settings`, Super Admin only (menu row `App settings`, `api/migrations-auth/0009`). Asks `/setup/status` (proxied, and routed by nginx) while the app restarts |
19
+ | `src/api/monitor.js` | `createMonitorApi({ fetch: authFetch, stream: authEventStream })` — every call with the sign-in token |
20
+ | `src/pages/Home.jsx` | `@xeplr/ui-monitor`'s `ServerPage` on that API: the server itself |
21
+ | `src/pages/Monitor.jsx` | `@xeplr/ui-monitor`'s `MonitorPage` on that API |
22
+
23
+ ## Rules
24
+
25
+ - `authFetch` returns the **parsed body**, not a Response — no `.json()`.
26
+ - A side-rail item needs an **icon** (a collapsed rail shows icons only) and its key must exist as a menu row (`Home` in `api/migrations-auth/0007`, `Monitor` in `0006`), or it is dropped silently. Give it its **`path`** too: that is how the rail marks the page you are on.
27
+ - **`pages.json` lists every route.** Home and Monitor are `webOnly`: written by hand, since the server's numbers, services, processes and live logs are not forms. The pre-commit hook (`.githooks/pre-commit`, set up by `npm install` here) prints that on every commit, with `xeplr-factory pages` (`@xeplr/ui-factory`, a dev dependency for that only).
28
+ - Phones: below 640px the rail becomes a bar across the top (`@xeplr/ui-account`) and the Monitor page stacks its list above the selected service; its tables scroll inside their own box.
29
+ - Set page backgrounds on a container inside the theme, never on `body`.
package/ui/index.html ADDED
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <link rel="icon" type="image/svg+xml" href="/logo.svg" />
7
+ <title>Xeplr Monitor</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.jsx"></script>
12
+ </body>
13
+ </html>