easy-devops 1.2.1 → 1.3.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 (126) hide show
  1. package/README.md +97 -6
  2. package/dist/ui/assets/index-B6zdwEnG.css +1 -0
  3. package/dist/ui/assets/index-Cy0oNmul.js +442 -0
  4. package/dist/ui/assets/socket-DwLPrgsr.js +1 -0
  5. package/dist/ui/assets/socket-K5ttLD2q.js +65 -0
  6. package/dist/ui/brand/apple-touch-icon.png +0 -0
  7. package/dist/ui/brand/favicon-16.png +0 -0
  8. package/dist/ui/brand/favicon-32.png +0 -0
  9. package/dist/ui/brand/favicon-light-16.png +0 -0
  10. package/dist/ui/brand/favicon-light-32.png +0 -0
  11. package/dist/ui/brand/favicon.ico +0 -0
  12. package/dist/ui/brand/icon-192.png +0 -0
  13. package/dist/ui/brand/icon-48.png +0 -0
  14. package/dist/ui/brand/icon-512.png +0 -0
  15. package/dist/ui/brand/icon-64-light.png +0 -0
  16. package/dist/ui/brand/icon-64.png +0 -0
  17. package/dist/ui/brand/logo-dark.png +0 -0
  18. package/dist/ui/brand/logo-light.png +0 -0
  19. package/dist/ui/brand/mark-dark.png +0 -0
  20. package/dist/ui/brand/mark-light.png +0 -0
  21. package/dist/ui/index.html +71 -0
  22. package/install.ps1 +188 -1
  23. package/install.sh +254 -29
  24. package/package.json +15 -4
  25. package/src/cli/dash.js +110 -0
  26. package/src/cli/index.js +237 -106
  27. package/src/cli/managers/domain-manager.js +60 -40
  28. package/src/cli/managers/ssl-manager.js +47 -330
  29. package/src/cli/menu.js +156 -0
  30. package/src/cli/menus/cleanup.js +205 -0
  31. package/src/cli/menus/dashboard.js +92 -1
  32. package/src/cli/menus/runtime.js +236 -0
  33. package/src/cli/menus/service.js +764 -0
  34. package/src/cli/menus/settings.js +176 -8
  35. package/src/cli/menus/uninstall.js +167 -0
  36. package/src/cli/menus/update.js +221 -65
  37. package/src/core/acme-challenge.js +273 -0
  38. package/src/core/cert-operations.js +189 -0
  39. package/src/{dashboard/lib → core}/cert-reader.js +2 -2
  40. package/src/core/cert-renewal.js +494 -0
  41. package/src/core/cleanup.js +600 -0
  42. package/src/core/config.js +169 -2
  43. package/src/core/daemon/ipc.js +292 -0
  44. package/src/core/daemon/lock.js +294 -0
  45. package/src/core/daemon/run.js +241 -0
  46. package/src/core/daemon/stopRequest.js +162 -0
  47. package/src/core/db.js +37 -8
  48. package/src/core/deploy/apps.js +491 -0
  49. package/src/core/deploy/domainLink.js +200 -0
  50. package/src/core/deploy/engine.js +973 -0
  51. package/src/core/deploy/ezfile.js +361 -0
  52. package/src/core/deploy/github.js +239 -0
  53. package/src/core/deploy/githubApi.js +261 -0
  54. package/src/core/deploy/hookServer.js +325 -0
  55. package/src/core/deploy/hubCommands.js +267 -0
  56. package/src/core/deploy/launcher.js +57 -0
  57. package/src/core/deploy/status.js +91 -0
  58. package/src/core/deploy/store.js +398 -0
  59. package/src/core/domainNotifier.js +94 -28
  60. package/src/core/domains-db.js +234 -0
  61. package/src/core/events.js +94 -2
  62. package/src/core/hub/agent.js +842 -0
  63. package/src/core/hubLink.js +306 -0
  64. package/src/core/hubPermissions.js +430 -0
  65. package/src/core/installSource.js +162 -0
  66. package/src/core/jobs/bus.js +120 -0
  67. package/src/core/jobs/index.js +371 -0
  68. package/src/core/jobs/monitors.js +368 -0
  69. package/src/core/jobs/owner.js +217 -0
  70. package/src/core/jobs/revisionWatcher.js +106 -0
  71. package/src/core/nginx-apply.js +213 -0
  72. package/src/core/nginx-conf-generator.js +253 -17
  73. package/src/{dashboard/lib → core}/nginx-service.js +18 -9
  74. package/src/core/notifications/claim.js +214 -0
  75. package/src/core/notifications/dispatch.js +154 -0
  76. package/src/core/notifier.js +31 -1
  77. package/src/core/passwords.js +172 -0
  78. package/src/core/permissions.js +8 -4
  79. package/src/core/platform.js +709 -2
  80. package/src/core/probeCache.js +258 -0
  81. package/src/core/purge.js +372 -0
  82. package/src/core/runner.js +488 -0
  83. package/src/core/service/acl.js +226 -0
  84. package/src/core/service/dataDir.js +345 -0
  85. package/src/core/service/index.js +1128 -0
  86. package/src/core/service/legacy.js +218 -0
  87. package/src/core/service/runtime.js +446 -0
  88. package/src/core/service/runtimeUpdate.js +800 -0
  89. package/src/core/service/systemd.js +458 -0
  90. package/src/core/service/windowsPersonal.js +530 -0
  91. package/src/core/service/windowsService.js +576 -0
  92. package/src/core/service/winsw.js +260 -0
  93. package/src/core/setupCode.js +331 -0
  94. package/src/core/shell.js +70 -7
  95. package/src/core/ssl-issuer.js +627 -0
  96. package/src/core/updater.js +295 -0
  97. package/src/core/validators.js +99 -0
  98. package/src/dashboard/controllers/authController.js +302 -15
  99. package/src/dashboard/controllers/deploymentsController.js +479 -0
  100. package/src/dashboard/controllers/domainsController.js +39 -52
  101. package/src/dashboard/controllers/hubController.js +135 -0
  102. package/src/dashboard/controllers/nginxController.js +21 -3
  103. package/src/dashboard/controllers/processesController.js +368 -0
  104. package/src/dashboard/controllers/settingsController.js +180 -12
  105. package/src/dashboard/controllers/sslController.js +171 -10
  106. package/src/dashboard/lib/daemonBridge.js +163 -0
  107. package/src/dashboard/lib/localRequest.js +235 -0
  108. package/src/dashboard/lib/loginRateLimit.js +119 -0
  109. package/src/dashboard/lib/requireAuth.js +80 -0
  110. package/src/dashboard/public/js/app.js +489 -19
  111. package/src/dashboard/routes/auth.js +10 -10
  112. package/src/dashboard/routes/deployments.js +46 -0
  113. package/src/dashboard/routes/domains.js +9 -0
  114. package/src/dashboard/routes/hub.js +22 -0
  115. package/src/dashboard/routes/nginx.js +9 -0
  116. package/src/dashboard/routes/processes.js +29 -0
  117. package/src/dashboard/routes/settings.js +9 -0
  118. package/src/dashboard/routes/ssl.js +9 -0
  119. package/src/dashboard/server.js +288 -21
  120. package/src/dashboard/socketManager.js +171 -207
  121. package/src/dashboard/views/index.ejs +1 -0
  122. package/src/dashboard/views/partials/login.ejs +68 -7
  123. package/src/dashboard/views/partials/processes-panel.ejs +261 -0
  124. package/src/dashboard/views/partials/settings-panel.ejs +287 -0
  125. package/src/dashboard/views/partials/sidebar.ejs +2 -0
  126. package/src/dashboard/lib/domains-db.js +0 -51
@@ -1,203 +1,151 @@
1
- import http from 'http';
1
+ /**
2
+ * dashboard/socketManager.js
3
+ *
4
+ * The browser-facing Socket.io layer. It no longer DOES any monitoring.
5
+ *
6
+ * It used to: nginx polling, domain health probes, certificate checks and the
7
+ * notification decisions all lived here, driven by intervals that only ran
8
+ * while a browser was connected. That is why none of it worked without an open
9
+ * dashboard, and why it could not move into a service.
10
+ *
11
+ * All of it now lives in core/jobs/, runs in whichever process owns the jobs,
12
+ * and arrives here as events on core/jobs/bus.js — published either by the
13
+ * monitors in this process, or by the daemon over IPC and republished onto the
14
+ * bus by dashboard/lib/daemonBridge.js. This module's whole job is to forward
15
+ * them to connected browsers unchanged, which is why the bus uses the names
16
+ * and payloads from docs/api-contract.md.
17
+ *
18
+ * What is still genuinely socket work and stays here: the session and
19
+ * local-request guards on the handshake, and the live log tails — a tail exists
20
+ * only for a client that is watching it, and dies with that client.
21
+ */
22
+
2
23
  import { spawn } from 'child_process';
3
- import path from 'path';
4
24
  import { Server as SocketIO } from 'socket.io';
5
25
 
6
- import { getStatus } from './lib/nginx-service.js';
7
- import { listAllCerts } from './lib/cert-reader.js';
26
+ import { socketRequireAuth } from './lib/requireAuth.js';
27
+ import { socketRequireLocalRequest } from './lib/localRequest.js';
8
28
  import { loadConfig } from '../core/config.js';
9
- import { dbGet } from '../core/db.js';
10
- import {
11
- createNginxDownEvent,
12
- createNginxRecoveredEvent,
13
- createDomainDownEvent,
14
- createDomainRecoveredEvent,
15
- } from '../core/events.js';
16
- import { sendNotification } from '../core/notifier.js';
17
- import {
18
- getEffectiveChannelIds,
19
- getAllDomainChannelIds,
20
- shouldSendNotification,
21
- } from '../core/domainNotifier.js';
29
+ import { nginxLogPath } from '../core/platform.js';
30
+ import { publish, subscribeAll } from '../core/jobs/bus.js';
22
31
 
23
32
  let connectedClients = 0;
24
33
  const activeTails = new Map();
25
34
 
35
+ let ioServer = null;
36
+ let unsubscribeBus = null;
37
+
26
38
  /**
27
- * Emit nginx status and handle notification state transitions.
28
- * Uses state tracking to prevent spam and support recovery notifications.
39
+ * The most recent payload for each replayable event.
40
+ *
41
+ * A newly opened tab has to show something immediately. The monitors publish
42
+ * on their own schedule — domain health every 60 seconds — so without this a
43
+ * tab opened just after a poll would sit empty until the next one. Previously
44
+ * the fix was to run a fresh poll per connection; that does not work when the
45
+ * polling happens in another process, and it meant every opened tab triggered
46
+ * real work.
47
+ *
48
+ * `service:changed` is cached for the same reason, and matters more: a tab
49
+ * that opens while the daemon is already running must render the banner right
50
+ * away rather than waiting for the next hand-over to tell it anything.
51
+ *
52
+ * Only the state-like events are cached. `notification:new` is not: it is a
53
+ * discrete thing that happened, and replaying old notifications into each new
54
+ * tab would announce outages that are long over.
29
55
  */
30
- async function emitNginxStatus(target) {
31
- try {
32
- const status = await getStatus();
33
- target.emit('nginx:status', status);
34
-
35
- const currentStatus = status.running ? 'up' : 'down';
36
- const decision = shouldSendNotification(null, 'nginx_down', currentStatus);
37
-
38
- if (decision.shouldNotify) {
39
- let event;
40
- if (decision.reason === 'recovery') {
41
- event = createNginxRecoveredEvent();
42
- } else {
43
- event = createNginxDownEvent();
44
- }
45
-
46
- console.log(`[socketManager] Sending nginx notification: ${decision.reason}`);
47
- target.emit('notification:new', event);
48
-
49
- // External channel routing (fire-and-forget, isolated)
50
- try {
51
- const channels = getAllDomainChannelIds('nginx_down');
52
- await sendNotification(event, channels);
53
- } catch (err) {
54
- console.error('[socketManager] sendNotification failed:', err.message);
55
- }
56
- }
57
- } catch (err) {
58
- target.emit('nginx:status', { running: false, version: null, pid: null, error: err.message });
59
- }
60
- }
56
+ const REPLAYABLE = ['nginx:status', 'domain:health', 'service:changed'];
57
+ const lastKnown = new Map();
61
58
 
62
59
  /**
63
- * Emit cert expiry notifications.
64
- * Note: Cert expiry doesn't use state tracking because it's a time-based event,
65
- * not a state transition. We notify whenever a cert is expiring, regardless of
66
- * whether we notified before.
60
+ * Initialize the Socket.IO server.
61
+ *
62
+ * @param {import('http').Server} httpServer
63
+ * @param {Function} sessionMiddleware Shared with Express so sockets see the same session
64
+ * @param {Function} getBinding Returns the current { port, bindAddress }
65
+ * @returns {import('socket.io').Server}
67
66
  */
68
- async function emitCertNotifications(target) {
69
- try {
70
- const certs = await listAllCerts();
71
- for (const cert of certs) {
72
- if (cert.daysLeft !== null && cert.daysLeft < 30) {
73
- const event = {
74
- id: `cert-expiry-${cert.domain}-${Date.now()}`,
75
- type: 'cert_expiry',
76
- severity: cert.daysLeft < 10 ? 'danger' : 'warning',
77
- message: `🔒 SSL cert for ${cert.domain} expires in ${cert.daysLeft} day${cert.daysLeft === 1 ? '' : 's'}`,
78
- domain: cert.domain,
79
- timestamp: Date.now(),
80
- };
81
- target.emit('notification:new', event);
82
-
83
- // External channel routing (fire-and-forget, isolated)
84
- try {
85
- const channels = getEffectiveChannelIds(cert.domain, 'cert_expiry');
86
- await sendNotification(event, channels);
87
- } catch (err) {
88
- console.error('[socketManager] sendNotification failed:', err.message);
89
- }
90
- }
91
- }
92
- } catch {
93
- /* non-fatal */
67
+ function initSocket(httpServer, sessionMiddleware, getBinding) {
68
+ const io = new SocketIO(httpServer);
69
+ ioServer = io;
70
+
71
+ // The socket stream is not a lesser surface than the REST API: it carries
72
+ // nginx status, domain health and live log tails. It gets the same session
73
+ // check.
74
+ //
75
+ // `io.engine.use` runs the express-session middleware on the handshake
76
+ // request, which is what puts `socket.request.session` in place for
77
+ // socketRequireAuth to read. Without the middleware there is no session
78
+ // object at all, and the guard then refuses every connection — which is the
79
+ // correct direction to fail, but would break the dashboard, so it is worth
80
+ // noticing rather than shipping.
81
+ if (typeof sessionMiddleware === 'function') {
82
+ io.engine.use(sessionMiddleware);
83
+ } else {
84
+ console.error('[socketManager] no session middleware supplied — refusing all socket connections');
94
85
  }
95
- }
96
86
 
97
- /**
98
- * Check if a domain backend is responding.
99
- */
100
- function checkDomainHealth(host, port) {
101
- return new Promise((resolve) => {
102
- const req = http.request(
103
- {
104
- host,
105
- port: Number(port),
106
- path: '/',
107
- method: 'HEAD',
108
- timeout: 5000,
109
- },
110
- (res) => {
111
- resolve({ up: true, status: res.statusCode });
112
- res.resume();
113
- }
114
- );
115
- req.on('timeout', () => {
116
- req.destroy();
117
- resolve({ up: false });
118
- });
119
- req.on('error', () => resolve({ up: false }));
120
- req.end();
87
+ // Host / Origin / X-EZ-Request, before the session check — the handshake is
88
+ // as reachable from a hostile page as any POST is, and a socket has no
89
+ // "safe method", so the custom header is required unconditionally.
90
+ //
91
+ // This is why the browser client must NOT force transports: ['websocket']:
92
+ // browsers cannot set headers on a WebSocket upgrade. socket.io's default
93
+ // starts with HTTP polling, where extraHeaders does apply, and the
94
+ // handshake is authenticated there before any upgrade happens.
95
+ if (typeof getBinding === 'function') {
96
+ io.use(socketRequireLocalRequest(getBinding));
97
+ } else {
98
+ console.error('[socketManager] no binding supplied — refusing all socket connections');
99
+ io.use((socket, next) => next(new Error('FORBIDDEN')));
100
+ }
101
+
102
+ io.use(socketRequireAuth);
103
+
104
+ // One subscription for the whole server, not one per client: these events are
105
+ // broadcasts, and subscribing per socket would deliver each one as many times
106
+ // as there are tabs open.
107
+ unsubscribeBus = subscribeAll((event, payload) => {
108
+ if (REPLAYABLE.includes(event)) lastKnown.set(event, payload);
109
+ if (connectedClients > 0) io.emit(event, payload);
121
110
  });
122
- }
123
111
 
124
- /**
125
- * Emit domain health status and handle notification state transitions.
126
- * Uses state tracking to:
127
- * 1. Prevent spam (don't re-notify if already down)
128
- * 2. Send recovery notifications when domain comes back up
129
- */
130
- async function emitDomainHealth(target) {
131
- try {
132
- const domains = dbGet('domains') || [];
133
- const results = await Promise.all(
134
- domains.map(async (d) => {
135
- const host = d.backendHost || '127.0.0.1';
136
- const port = d.port || 80;
137
-
138
- // Skip external URL backends
139
- if (typeof host === 'string' && host.startsWith('http')) return { name: d.name, up: null };
140
-
141
- const { up } = await checkDomainHealth(host, port);
142
- return { name: d.name, up, port, host };
143
- })
144
- );
145
-
146
- target.emit('domain:health', results);
147
-
148
- // Process state transitions for each domain
149
- for (const result of results) {
150
- if (result.up === null) continue; // Skip external URL backends
151
-
152
- const currentStatus = result.up ? 'up' : 'down';
153
- const decision = shouldSendNotification(result.name, 'domain_health', currentStatus);
154
-
155
- if (decision.shouldNotify) {
156
- let event;
157
- if (decision.reason === 'recovery') {
158
- event = createDomainRecoveredEvent(result.name, result.port);
159
- } else {
160
- event = createDomainDownEvent(result.name, result.port);
161
- }
162
-
163
- console.log(`[socketManager] Sending domain health notification for ${result.name}: ${decision.reason}`);
164
- target.emit('notification:new', event);
165
-
166
- try {
167
- const channelIds = getEffectiveChannelIds(result.name, 'domain_health');
168
- await sendNotification(event, channelIds);
169
- } catch (err) {
170
- console.error('[socketManager] domain health sendNotification failed:', err.message);
171
- }
172
- }
112
+ io.on('connection', (socket) => {
113
+ connectedClients++;
114
+
115
+ // Whatever we last heard, so the UI renders immediately instead of waiting
116
+ // for the next poll in whichever process owns the jobs.
117
+ for (const event of REPLAYABLE) {
118
+ if (lastKnown.has(event)) socket.emit(event, lastKnown.get(event));
173
119
  }
174
- } catch (err) {
175
- console.error('[socketManager] emitDomainHealth error:', err.message);
176
- }
177
- }
178
120
 
179
- /**
180
- * Get the path to a log file.
181
- */
182
- function getLogPath(logFile) {
183
- const { nginxDir } = loadConfig();
184
- const file = logFile === 'access' ? 'access.log' : 'error.log';
121
+ socket.on('logs:subscribe', ({ logFile } = {}) => startTail(socket, logFile || 'error'));
122
+ socket.on('logs:unsubscribe', () => stopTail(socket.id));
185
123
 
186
- // Linux standard path first, fall back to nginxDir/logs/
187
- if (process.platform !== 'win32') {
188
- return `/var/log/nginx/${file}`;
189
- }
190
- return path.join(nginxDir, 'logs', file);
124
+ socket.on('disconnect', () => {
125
+ connectedClients--;
126
+ stopTail(socket.id);
127
+ });
128
+ });
129
+
130
+ return io;
191
131
  }
192
132
 
133
+ // ─── Live log tails ───────────────────────────────────────────────────────────
134
+
193
135
  /**
194
- * Start tailing a log file for a socket.
136
+ * Starts tailing a log file for one socket.
137
+ *
138
+ * `-n 50` / `-Tail 50` is what satisfies the contract's promise that a
139
+ * subscribe replays the last 50 lines before streaming: the tail command does
140
+ * both in one call, so there is no window between the replay and the live
141
+ * stream in which a line could be missed.
195
142
  */
196
143
  function startTail(socket, logFile) {
197
- // Kill any existing tail for this socket
198
144
  stopTail(socket.id);
199
145
 
200
- const logPath = getLogPath(logFile);
146
+ const { nginxDir } = loadConfig();
147
+ const logPath = nginxLogPath(nginxDir, logFile === 'access' ? 'access' : 'error');
148
+
201
149
  const args = process.platform === 'win32'
202
150
  ? ['Get-Content', '-Path', logPath, '-Wait', '-Tail', '50']
203
151
  : ['-n', '50', '-f', logPath];
@@ -212,7 +160,7 @@ function startTail(socket, logFile) {
212
160
  child.stdout.on('data', (chunk) => {
213
161
  buf += chunk.toString();
214
162
  const lines = buf.split('\n');
215
- buf = lines.pop(); // keep incomplete line in buffer
163
+ buf = lines.pop(); // keep the incomplete line in the buffer
216
164
  for (const line of lines) {
217
165
  if (line.trim()) socket.emit('logs:line', { line: line.trim(), logFile });
218
166
  }
@@ -226,9 +174,7 @@ function startTail(socket, logFile) {
226
174
  activeTails.set(socket.id, { process: child, logFile });
227
175
  }
228
176
 
229
- /**
230
- * Stop tailing a log file for a socket.
231
- */
177
+ /** Stops the tail belonging to one socket. */
232
178
  function stopTail(socketId) {
233
179
  const entry = activeTails.get(socketId);
234
180
  if (entry) {
@@ -239,44 +185,62 @@ function stopTail(socketId) {
239
185
  }
240
186
  }
241
187
 
188
+ // ─── Outbound helper ──────────────────────────────────────────────────────────
189
+
242
190
  /**
243
- * Initialize the Socket.IO server.
191
+ * Tells every open dashboard tab that a section changed, so the UI can refresh
192
+ * just that part instead of reloading the page.
193
+ *
194
+ * Used when a change did NOT originate in this browser — most importantly when
195
+ * the Hub applies a command through core/hub/agent.js, or when another process
196
+ * moves the revision counter.
197
+ *
198
+ * It publishes to the job bus rather than emitting at the socket server
199
+ * directly, so the same call works in the daemon, which has no socket server,
200
+ * and still reaches browsers through IPC. Safe to call before initSocket().
201
+ *
202
+ * @param {'domains'|'ssl'|'nginx'|'settings'} section
203
+ * @param {Object} [detail] Optional extra context for the client
244
204
  */
245
- function initSocket(httpServer) {
246
- const io = new SocketIO(httpServer);
205
+ function emitLocalChange(section, detail = {}) {
206
+ publish('local:changed', { section, source: 'hub', at: Date.now(), ...detail });
207
+ }
247
208
 
248
- io.on('connection', (socket) => {
249
- connectedClients++;
209
+ /**
210
+ * Stops everything initSocket() started: the bus subscription, every active
211
+ * log tail (each is a spawned child process), and the Socket.io server itself.
212
+ * Safe to call more than once.
213
+ *
214
+ * It does NOT stop the background jobs — server.js owns those, because their
215
+ * lifetime is the process's, not the socket server's.
216
+ *
217
+ * @returns {Promise<void>} Resolves once the Socket.io server has closed
218
+ */
219
+ async function stopSocket() {
220
+ if (unsubscribeBus) {
221
+ unsubscribeBus();
222
+ unsubscribeBus = null;
223
+ }
250
224
 
251
- emitNginxStatus(socket);
252
- emitCertNotifications(socket);
225
+ // Kill the tail/Get-Content children; stopTail() removes each map entry.
226
+ for (const socketId of [...activeTails.keys()]) stopTail(socketId);
253
227
 
254
- socket.on('logs:subscribe', ({ logFile }) => startTail(socket, logFile || 'error'));
255
- socket.on('logs:unsubscribe', () => stopTail(socket.id));
228
+ connectedClients = 0;
229
+ lastKnown.clear();
256
230
 
257
- // Send initial domain health on connect
258
- emitDomainHealth(socket);
231
+ const io = ioServer;
232
+ ioServer = null;
233
+ if (!io) return;
259
234
 
260
- socket.on('disconnect', () => {
261
- connectedClients--;
262
- stopTail(socket.id);
235
+ await new Promise((resolve) => {
236
+ // close() disconnects clients and stops accepting new ones. It is given a
237
+ // short grace period so a wedged client cannot block shutdown.
238
+ const done = setTimeout(resolve, 2000);
239
+ io.close(() => {
240
+ clearTimeout(done);
241
+ resolve();
263
242
  });
264
243
  });
265
-
266
- // Poll domain health every 60 seconds
267
- setInterval(() => {
268
- if (connectedClients > 0) emitDomainHealth(io);
269
- }, 60_000);
270
-
271
- // Broadcast nginx status to all clients every 5 seconds
272
- setInterval(() => {
273
- if (connectedClients > 0) emitNginxStatus(io);
274
- }, 5000);
275
-
276
- // Check cert expiry every 12 hours
277
- setInterval(() => {
278
- if (connectedClients > 0) emitCertNotifications(io);
279
- }, 12 * 60 * 60 * 1000);
280
244
  }
281
245
 
282
- export { initSocket };
246
+ export { initSocket, stopSocket, emitLocalChange };
@@ -689,6 +689,7 @@ class="theme-accent-circle"
689
689
  <%- include('partials/ssl-panel.ejs') %>
690
690
  <%- include('partials/domains-panel.ejs') %>
691
691
  <%- include('partials/settings-panel.ejs') %>
692
+ <%- include('partials/processes-panel.ejs') %>
692
693
  <%- include('partials/logs-panel.ejs') %>
693
694
  </div>
694
695
  </transition>
@@ -95,7 +95,34 @@
95
95
 
96
96
  <!-- Login Card -->
97
97
  <div class="login-card w-full text-left" style="animation: card-enter 500ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;">
98
- <div class="mb-6">
98
+ <!--
99
+ First run: no password exists yet, so the only thing on offer is
100
+ setting one. There is deliberately no way to skip this — an empty
101
+ password used to be a valid login.
102
+ -->
103
+ <template v-if="login.needsSetup">
104
+ <p style="
105
+ font-size: 13px; color: var(--color-muted);
106
+ margin-top: 0; margin-bottom: 20px; font-weight: 500; line-height: 1.6;
107
+ ">
108
+ No dashboard password is set yet. Choose one to protect this dashboard —
109
+ at least {{ login.minLength }} characters.
110
+ </p>
111
+
112
+ <div class="mb-4">
113
+ <label class="login-label">New password</label>
114
+ <input v-model="login.password" type="password" class="login-input"
115
+ :placeholder="'At least ' + login.minLength + ' characters'" @keyup.enter="doSetup" />
116
+ </div>
117
+
118
+ <div class="mb-6">
119
+ <label class="login-label">Confirm password</label>
120
+ <input v-model="login.confirm" type="password" class="login-input"
121
+ placeholder="Repeat the password" @keyup.enter="doSetup" />
122
+ </div>
123
+ </template>
124
+
125
+ <div v-else class="mb-6">
99
126
  <label class="login-label">Password</label>
100
127
  <input v-model="login.password" type="password" class="login-input" placeholder="Enter dashboard password" @keyup.enter="doLogin" />
101
128
  </div>
@@ -113,18 +140,52 @@
113
140
  {{ login.error }}
114
141
  </div>
115
142
 
116
- <button @click="doLogin" :disabled="login.loading" class="login-btn gap-2">
143
+ <button v-if="login.needsSetup" @click="doSetup" :disabled="login.loading" class="login-btn gap-2">
117
144
  <svg v-if="login.loading" class="w-4 h-4 animate-spin inline-block -ml-1" fill="none" viewBox="0 0 24 24">
118
145
  <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
119
146
  <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path>
120
147
  </svg>
121
- {{ login.loading ? 'Signing in...' : 'Sign In' }}
148
+ {{ login.loading ? 'Saving...' : 'Set a password' }}
122
149
  </button>
123
150
 
124
- <p style="
125
- text-align: center; font-size: 12px; color: var(--color-muted);
126
- margin-top: 24px; margin-bottom: 0; font-weight: 500;
127
- ">No password set? Leave blank and press Sign In.</p>
151
+ <!--
152
+ Shown only when the server says so: the dashboard must listen on this
153
+ machine only AND this page must have been opened from this machine.
154
+ Anywhere else the option does not appear at all.
155
+ -->
156
+ <template v-if="login.needsSetup && login.canUseNoPassword">
157
+ <div style="
158
+ display: flex; align-items: center; gap: 12px;
159
+ margin: 20px 0 16px; color: var(--color-muted);
160
+ font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700;
161
+ ">
162
+ <span style="flex: 1; height: 1px; background: var(--color-border);"></span>
163
+ or
164
+ <span style="flex: 1; height: 1px; background: var(--color-border);"></span>
165
+ </div>
166
+
167
+ <button @click="doSetupNoPassword" :disabled="login.loading"
168
+ class="login-btn gap-2"
169
+ style="background: transparent; border: 1px solid var(--color-border); color: var(--color-foreground);">
170
+ No password (this machine only)
171
+ </button>
172
+
173
+ <p style="
174
+ text-align: center; font-size: 11px; color: var(--color-muted);
175
+ margin-top: 12px; margin-bottom: 0; font-weight: 500; line-height: 1.6;
176
+ ">
177
+ The dashboard stays reachable from this computer only. You can set a
178
+ password later in Settings.
179
+ </p>
180
+ </template>
181
+
182
+ <button v-else @click="doLogin" :disabled="login.loading" class="login-btn gap-2">
183
+ <svg v-if="login.loading" class="w-4 h-4 animate-spin inline-block -ml-1" fill="none" viewBox="0 0 24 24">
184
+ <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
185
+ <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path>
186
+ </svg>
187
+ {{ login.loading ? 'Signing in...' : 'Sign In' }}
188
+ </button>
128
189
  </div>
129
190
 
130
191
  <!-- Bottom Theme Controls (Pill) -->