@fabioplunser/epd 0.4.0 → 0.5.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.
package/dist/cli.js CHANGED
@@ -1,4 +1,6 @@
1
1
  // @bun
2
+ var __require = import.meta.require;
3
+
2
4
  // src/cli.ts
3
5
  import { parseArgs } from "util";
4
6
 
@@ -2426,7 +2428,7 @@ function staticConfig(d, where = CONTAINER_PATHS) {
2426
2428
  global: { checkNewVersion: false, sendAnonymousUsage: false },
2427
2429
  log: { level: d.logLevel },
2428
2430
  ...d.accessLog ? { accessLog: {} } : {},
2429
- ...d.dashboard ? { api: { dashboard: true } } : {},
2431
+ ...d.dashboard ? { api: { dashboard: true, insecure: true } } : {},
2430
2432
  entryPoints,
2431
2433
  providers: {
2432
2434
  file: { directory: where.dynamicDir, watch: true },
@@ -2595,6 +2597,8 @@ function containerSpec(d, cfg, staticHash) {
2595
2597
  ];
2596
2598
  for (const port of Object.values(d.entrypoints))
2597
2599
  args.push("-p", `${port}:${port}`);
2600
+ if (d.dashboard)
2601
+ args.push("-p", "127.0.0.1:8080:8080");
2598
2602
  if (d.dnsEnv.length)
2599
2603
  args.push("--env-file", p.proxyEnv);
2600
2604
  args.push(d.image);
@@ -4676,7 +4680,7 @@ Options
4676
4680
  var proxy = {
4677
4681
  name: "proxy",
4678
4682
  summary: "Inspect or restart the shared Traefik proxy",
4679
- options: { host: { type: "string" }, lines: { type: "string", short: "n" }, follow: { type: "boolean", short: "f" } },
4683
+ options: { host: { type: "string" }, lines: { type: "string", short: "n" }, follow: { type: "boolean", short: "f" }, port: { type: "string", short: "p" } },
4680
4684
  help: () => `${c.bold("epd proxy <status|reboot|logs|routes|remove>")}
4681
4685
 
4682
4686
  One Traefik container per server, shared by every epd app on it. Rebooting it
@@ -4685,13 +4689,15 @@ briefly interrupts *all* sites on that server; the apps themselves keep running.
4685
4689
  status Is it up, on which image, with which entrypoints
4686
4690
  reboot Recreate it from the current configuration
4687
4691
  logs Traefik's own logs (certificates, routing errors)
4688
- routes The route file epd wrote for this app
4689
- remove Remove this app's routes and stop the proxy if nothing else needs it
4692
+ routes The route file epd wrote for this app
4693
+ dashboard Open a secure SSH tunnel to the Traefik web UI & launch browser
4694
+ remove Remove this app's routes and stop the proxy if nothing else needs it
4690
4695
 
4691
4696
  Options
4692
4697
  --host <ip> Only this host
4693
4698
  -n, --lines <n> Log lines (default 100)
4694
- -f, --follow Stream logs`,
4699
+ -f, --follow Stream logs
4700
+ -p, --port <port> Local dashboard port (default 8080)`,
4695
4701
  async run(ctx) {
4696
4702
  const loaded = ctx.load();
4697
4703
  const cfg = loaded.config;
@@ -4751,6 +4757,30 @@ Options
4751
4757
  }
4752
4758
  return;
4753
4759
  }
4760
+ case "dashboard": {
4761
+ const targetHost = hosts[0];
4762
+ if (!targetHost)
4763
+ throw new EpdError("No proxy hosts available");
4764
+ const localPort = Number(ctx.values.port) || 8080;
4765
+ const dashboardUrl = `http://localhost:${localPort}/dashboard/`;
4766
+ log.step(`Connecting to Traefik dashboard on ${c.bold(targetHost.name)}...`);
4767
+ const s = await proxyState(targetHost, cfg);
4768
+ if (!s.running) {
4769
+ throw new EpdError(`Proxy on ${targetHost.name} is not running. Run ${c.cyan("epd proxy reboot")} first.`);
4770
+ }
4771
+ log.info(`Forwarding local port ${c.bold(String(localPort))} -> 127.0.0.1:8080 on ${targetHost.name}`);
4772
+ log.ok(`Dashboard URL: ${c.cyan(dashboardUrl)}`);
4773
+ log.info(`Press Ctrl-C to close the dashboard tunnel.`);
4774
+ await openBrowser(dashboardUrl);
4775
+ const args = [...targetHost.sshOptions(), "-N", "-L", `${localPort}:127.0.0.1:8080`, targetHost.target];
4776
+ const proc = typeof process.isBun !== "undefined" ? Bun.spawn(["ssh", ...args], { stdout: "inherit", stderr: "inherit" }) : __require("child_process").spawn("ssh", args, { stdio: "inherit" });
4777
+ if (proc.exited) {
4778
+ await proc.exited;
4779
+ } else {
4780
+ await new Promise((resolve) => proc.on("close", resolve));
4781
+ }
4782
+ return;
4783
+ }
4754
4784
  case "remove": {
4755
4785
  for (const host of hosts) {
4756
4786
  await removeRoutes(host, cfg);
@@ -5736,7 +5766,7 @@ async function promptAutoUpdate(currentVersion) {
5736
5766
  }
5737
5767
 
5738
5768
  // src/version.ts
5739
- var VERSION = "0.4.0";
5769
+ var VERSION = "0.5.0";
5740
5770
 
5741
5771
  // src/commands/update.ts
5742
5772
  var update = {
@@ -5835,6 +5865,904 @@ Run ${c.cyan("epd auth cloudflare")} or ${c.cyan("epd auth hetzner")} to link an
5835
5865
  }
5836
5866
  };
5837
5867
 
5868
+ // src/commands/maintenance.ts
5869
+ function extractDomains(cfg) {
5870
+ const domains = new Set;
5871
+ for (const svc of cfg.services) {
5872
+ for (const r of svc.routes) {
5873
+ for (const h of r.hosts)
5874
+ domains.add(h);
5875
+ }
5876
+ }
5877
+ return Array.from(domains);
5878
+ }
5879
+ function maintenanceHtml(title, message, retrySeconds, appName) {
5880
+ return `<!DOCTYPE html>
5881
+ <html lang="en">
5882
+ <head>
5883
+ <meta charset="UTF-8">
5884
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5885
+ <title>${title} \u2014 ${appName}</title>
5886
+ <style>
5887
+ :root {
5888
+ --bg: #0b0f19;
5889
+ --card: #151c2e;
5890
+ --border: #232d48;
5891
+ --text: #f8fafc;
5892
+ --subtext: #94a3b8;
5893
+ --brand: #38bdf8;
5894
+ --accent: #6366f1;
5895
+ }
5896
+ * { box-sizing: border-box; margin: 0; padding: 0; }
5897
+ body {
5898
+ background-color: var(--bg);
5899
+ color: var(--text);
5900
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
5901
+ min-height: 100vh;
5902
+ display: flex;
5903
+ align-items: center;
5904
+ justify-content: center;
5905
+ padding: 1.5rem;
5906
+ }
5907
+ .card {
5908
+ background: var(--card);
5909
+ border: 1px solid var(--border);
5910
+ border-radius: 1.25rem;
5911
+ max-width: 32rem;
5912
+ width: 100%;
5913
+ padding: 2.5rem 2rem;
5914
+ text-align: center;
5915
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
5916
+ position: relative;
5917
+ overflow: hidden;
5918
+ }
5919
+ .card::before {
5920
+ content: "";
5921
+ position: absolute;
5922
+ top: 0; left: 0; right: 0;
5923
+ height: 4px;
5924
+ background: linear-gradient(90deg, var(--brand), var(--accent));
5925
+ }
5926
+ .icon-box {
5927
+ width: 4.5rem;
5928
+ height: 4.5rem;
5929
+ background: rgba(56, 189, 248, 0.1);
5930
+ border: 1px solid rgba(56, 189, 248, 0.2);
5931
+ border-radius: 1rem;
5932
+ display: inline-flex;
5933
+ align-items: center;
5934
+ justify-content: center;
5935
+ font-size: 2.25rem;
5936
+ margin-bottom: 1.5rem;
5937
+ animation: pulse 3s infinite ease-in-out;
5938
+ }
5939
+ @keyframes pulse {
5940
+ 0%, 100% { transform: scale(1); opacity: 1; }
5941
+ 50% { transform: scale(1.05); opacity: 0.85; }
5942
+ }
5943
+ h1 {
5944
+ font-size: 1.5rem;
5945
+ font-weight: 700;
5946
+ letter-spacing: -0.025em;
5947
+ margin-bottom: 0.75rem;
5948
+ }
5949
+ p {
5950
+ color: var(--subtext);
5951
+ font-size: 1rem;
5952
+ line-height: 1.6;
5953
+ margin-bottom: 1.75rem;
5954
+ }
5955
+ .badge {
5956
+ display: inline-flex;
5957
+ align-items: center;
5958
+ gap: 0.5rem;
5959
+ padding: 0.35rem 0.85rem;
5960
+ background: rgba(245, 158, 11, 0.1);
5961
+ border: 1px solid rgba(245, 158, 11, 0.3);
5962
+ border-radius: 9999px;
5963
+ color: #f59e0b;
5964
+ font-size: 0.825rem;
5965
+ font-weight: 600;
5966
+ margin-bottom: 1.5rem;
5967
+ }
5968
+ .dot {
5969
+ width: 0.5rem;
5970
+ height: 0.5rem;
5971
+ border-radius: 9999px;
5972
+ background: #f59e0b;
5973
+ animation: blink 1.5s infinite;
5974
+ }
5975
+ @keyframes blink {
5976
+ 0%, 100% { opacity: 1; }
5977
+ 50% { opacity: 0.3; }
5978
+ }
5979
+ .countdown {
5980
+ font-size: 0.875rem;
5981
+ color: var(--subtext);
5982
+ border-top: 1px solid var(--border);
5983
+ padding-top: 1.25rem;
5984
+ }
5985
+ </style>
5986
+ </head>
5987
+ <body>
5988
+ <div class="card">
5989
+ <div class="icon-box">\u26A1</div>
5990
+ <div class="badge"><span class="dot"></span> Maintenance Mode Active</div>
5991
+ <h1>${title}</h1>
5992
+ <p>${message}</p>
5993
+ <div class="countdown">
5994
+ Auto-refreshing in <span id="timer" style="font-weight: 600; color: var(--brand);">${retrySeconds}</span>s...
5995
+ </div>
5996
+ </div>
5997
+ <script>
5998
+ let remaining = ${retrySeconds};
5999
+ const timer = document.getElementById('timer');
6000
+ setInterval(() => {
6001
+ remaining--;
6002
+ if (remaining <= 0) {
6003
+ window.location.reload();
6004
+ } else if (timer) {
6005
+ timer.textContent = remaining;
6006
+ }
6007
+ }, 1000);
6008
+ </script>
6009
+ </body>
6010
+ </html>`;
6011
+ }
6012
+ function maintenanceYaml(appName, domains, port) {
6013
+ if (!domains.length)
6014
+ domains = ["localhost"];
6015
+ const hostRule = domains.map((d) => `Host(\`${d}\`)`).join(" || ");
6016
+ return `http:
6017
+ routers:
6018
+ ${appName}-maint-http:
6019
+ rule: "${hostRule}"
6020
+ entryPoints: ["web"]
6021
+ service: "${appName}-maint-svc"
6022
+ priority: 2000000000
6023
+ ${appName}-maint-https:
6024
+ rule: "${hostRule}"
6025
+ entryPoints: ["websecure"]
6026
+ service: "${appName}-maint-svc"
6027
+ priority: 2000000000
6028
+ tls: {}
6029
+ services:
6030
+ ${appName}-maint-svc:
6031
+ loadBalancer:
6032
+ servers:
6033
+ - url: "http://127.0.0.1:${port}"
6034
+ `;
6035
+ }
6036
+ var maintenance = {
6037
+ name: "maintenance",
6038
+ summary: "Toggle or inspect zero-downtime maintenance mode for this application",
6039
+ options: {
6040
+ message: { type: "string", short: "m" },
6041
+ title: { type: "string" },
6042
+ retry: { type: "string" },
6043
+ status: { type: "string" },
6044
+ host: { type: "string" }
6045
+ },
6046
+ help: () => `${c.bold("epd maintenance <on|off|status>")} \u2014 manage maintenance mode
6047
+
6048
+ Presents a responsive 503 Maintenance page to all public visitors via Traefik
6049
+ without stopping your backend applications or dropping SSL.
6050
+
6051
+ Commands
6052
+ on Enable maintenance mode and route all traffic to the maintenance page
6053
+ off Disable maintenance mode and resume live blue/green routing
6054
+ status Check if maintenance mode is currently active
6055
+
6056
+ Options
6057
+ -m, --message <text> Custom maintenance message
6058
+ --title <text> Custom page title (default: Maintenance in Progress)
6059
+ --retry <sec> Retry-After header and auto-refresh timer (default: 30)
6060
+ --status <code> HTTP response status code (default: 503)
6061
+ --host <ip> Run only on a specific host`,
6062
+ async run(ctx) {
6063
+ const loaded = ctx.load();
6064
+ const cfg = loaded.config;
6065
+ const action = ctx.positionals[0] ?? "status";
6066
+ let hostNames = allHosts(cfg);
6067
+ if (ctx.values.host)
6068
+ hostNames = hostNames.filter((h) => h === ctx.values.host);
6069
+ if (!hostNames.length)
6070
+ throw new EpdError("No hosts found in configuration");
6071
+ const hosts = hostNames.map((h) => host(h, cfg.ssh));
6072
+ const p = paths(cfg);
6073
+ const maintPort = (cfg.portBase || 31776) + 999;
6074
+ const domains = extractDomains(cfg);
6075
+ const maintDir = `${p.root}/maintenance/${cfg.name}`;
6076
+ const traefikDynamicFile = `${p.proxyDynamicDir}/${cfg.name}-maintenance.yml`;
6077
+ switch (action) {
6078
+ case "status": {
6079
+ for (const host of hosts) {
6080
+ const isActive = await host.test(`[ -f ${shq(traefikDynamicFile)} ]`);
6081
+ if (isActive) {
6082
+ log.plain(`${c.magenta(host.name)}: ${c.yellow(c.bold("MAINTENANCE ACTIVE"))} (routes overriding live app)`);
6083
+ } else {
6084
+ log.plain(`${c.magenta(host.name)}: ${c.green("Live")} (normal blue/green routing)`);
6085
+ }
6086
+ }
6087
+ return;
6088
+ }
6089
+ case "on": {
6090
+ const title = ctx.values.title || "Maintenance in Progress";
6091
+ const message = ctx.values.message || "We are currently performing scheduled maintenance. We will be back shortly.";
6092
+ const retrySec = Number(ctx.values.retry) || 30;
6093
+ const statusCode = Number(ctx.values.status) || 503;
6094
+ const html = maintenanceHtml(title, message, retrySec, cfg.name);
6095
+ const yml = maintenanceYaml(cfg.name, domains, maintPort);
6096
+ log.step(`Enabling maintenance mode on ${hosts.length} host(s)...`);
6097
+ await pool(hosts, 4, async (host) => {
6098
+ await host.exec(`mkdir -p ${shq(maintDir)} ${shq(p.proxyDynamicDir)}`);
6099
+ await host.writeFile(`${maintDir}/index.html`, html, "644");
6100
+ const pyServer = `import http.server, socketserver
6101
+ class Handler(http.server.BaseHTTPRequestHandler):
6102
+ def do_GET(self):
6103
+ self.send_response(${statusCode})
6104
+ self.send_header('Content-Type', 'text/html; charset=utf-8')
6105
+ self.send_header('Retry-After', '${retrySec}')
6106
+ self.end_headers()
6107
+ try:
6108
+ with open('${maintDir}/index.html', 'rb') as f:
6109
+ self.wfile.write(f.read())
6110
+ except Exception:
6111
+ self.wfile.write(b"<h1>Maintenance in Progress</h1>")
6112
+ def do_HEAD(self):
6113
+ self.send_response(${statusCode})
6114
+ self.send_header('Content-Type', 'text/html; charset=utf-8')
6115
+ self.send_header('Retry-After', '${retrySec}')
6116
+ self.end_headers()
6117
+ def log_message(self, format, *args):
6118
+ pass
6119
+
6120
+ socketserver.TCPServer.allow_reuse_address = True
6121
+ with socketserver.TCPServer(('127.0.0.1', ${maintPort}), Handler) as httpd:
6122
+ httpd.serve_forever()
6123
+ `;
6124
+ await host.writeFile(`${maintDir}/server.py`, pyServer, "755");
6125
+ await host.exec(`[ -f ${shq(maintDir)}/pid ] && kill $(cat ${shq(maintDir)}/pid) 2>/dev/null || true`);
6126
+ await host.exec(`docker rm -f epd-${cfg.name}-maint 2>/dev/null || true`);
6127
+ const hasPython = await host.test("command -v python3 >/dev/null 2>&1");
6128
+ if (hasPython) {
6129
+ await host.exec(`nohup python3 ${shq(maintDir)}/server.py >/dev/null 2>&1 & echo $! > ${shq(maintDir)}/pid`);
6130
+ } else {
6131
+ await host.exec(`docker run -d --name epd-${cfg.name}-maint --restart unless-stopped -p 127.0.0.1:${maintPort}:80 -v ${shq(maintDir)}:/usr/share/nginx/html:ro nginx:alpine >/dev/null 2>&1 || true`);
6132
+ }
6133
+ await host.writeFile(traefikDynamicFile, yml, "644");
6134
+ log.host(host.name, `maintenance mode enabled (${c.yellow(`HTTP ${statusCode}`)})`);
6135
+ });
6136
+ log.ok(`Maintenance mode active across all hosts for: ${domains.join(", ") || cfg.name}`);
6137
+ log.info(`Run ${c.cyan("epd maintenance off")} when ready to resume live traffic.`);
6138
+ return;
6139
+ }
6140
+ case "off": {
6141
+ log.step(`Disabling maintenance mode on ${hosts.length} host(s)...`);
6142
+ await pool(hosts, 4, async (host) => {
6143
+ await host.exec(`rm -f ${shq(traefikDynamicFile)}`);
6144
+ await host.exec(`[ -f ${shq(maintDir)}/pid ] && kill $(cat ${shq(maintDir)}/pid) 2>/dev/null || true`);
6145
+ await host.exec(`docker rm -f epd-${cfg.name}-maint 2>/dev/null || true`);
6146
+ await host.exec(`rm -rf ${shq(maintDir)}`);
6147
+ log.host(host.name, "maintenance mode disabled");
6148
+ });
6149
+ log.ok(`Maintenance mode disabled. Live traffic restored!`);
6150
+ return;
6151
+ }
6152
+ default:
6153
+ throw new EpdError(`Unknown action "${action}". Available: on, off, status`);
6154
+ }
6155
+ }
6156
+ };
6157
+
6158
+ // src/commands/ssl.ts
6159
+ import { X509Certificate } from "crypto";
6160
+ function parseAcmeCert(entry) {
6161
+ try {
6162
+ if (!entry.certificate)
6163
+ return null;
6164
+ const pem = Buffer.from(entry.certificate, "base64").toString("utf8");
6165
+ const cert = new X509Certificate(pem);
6166
+ const validTo = new Date(cert.validTo);
6167
+ const validFrom = new Date(cert.validFrom);
6168
+ const msRemaining = validTo.getTime() - Date.now();
6169
+ const daysRemaining = Math.floor(msRemaining / (1000 * 60 * 60 * 24));
6170
+ let status = "active";
6171
+ if (daysRemaining <= 0)
6172
+ status = "expired";
6173
+ else if (daysRemaining <= 14)
6174
+ status = "expiring_soon";
6175
+ const sans = cert.subjectAltName ? cert.subjectAltName.split(", ").map((s) => s.replace(/^DNS:/, "")) : [];
6176
+ const issuerMatch = cert.issuer.match(/O=([^,\n]+)/) || cert.issuer.match(/CN=([^,\n]+)/);
6177
+ const issuer = issuerMatch ? issuerMatch[1] : cert.issuer;
6178
+ const mainDomain = entry.domain?.main || cert.subject.replace(/^CN=/, "");
6179
+ return {
6180
+ mainDomain,
6181
+ sans: sans.filter((s) => s !== mainDomain),
6182
+ issuer: issuer || "Let's Encrypt",
6183
+ validFrom: validFrom.toISOString().split("T")[0] ?? "",
6184
+ validTo: validTo.toISOString().split("T")[0] ?? "",
6185
+ daysRemaining,
6186
+ status
6187
+ };
6188
+ } catch {
6189
+ return null;
6190
+ }
6191
+ }
6192
+ var ssl = {
6193
+ name: "ssl",
6194
+ aliases: ["certs"],
6195
+ summary: "Inspect and verify Let's Encrypt SSL/TLS certificates",
6196
+ options: {
6197
+ host: { type: "string" },
6198
+ json: { type: "boolean" }
6199
+ },
6200
+ help: () => `${c.bold("epd ssl [status]")} \u2014 inspect SSL certificates managed by Traefik
6201
+
6202
+ Displays certificates stored in /var/lib/epd/proxy/acme/acme.json, including
6203
+ domains, SANs, issuers, expiration dates, and days remaining.
6204
+
6205
+ Options
6206
+ --host <ip> Only inspect this host
6207
+ --json Output certificate metadata as JSON`,
6208
+ async run(ctx) {
6209
+ const loaded = ctx.load();
6210
+ const cfg = loaded.config;
6211
+ let names = proxyHosts(cfg);
6212
+ if (ctx.values.host)
6213
+ names = names.filter((h) => h === ctx.values.host);
6214
+ if (!names.length)
6215
+ throw new EpdError("No proxy hosts found in configuration");
6216
+ const hosts = names.map((h) => host(h, cfg.ssh));
6217
+ const p = paths(cfg);
6218
+ const acmeFilePath = `${p.acmeDir}/acme.json`;
6219
+ const allResults = {};
6220
+ for (const host of hosts) {
6221
+ log.step(`Checking SSL certificates on ${c.bold(host.name)}...`);
6222
+ const exists = await host.test(`[ -f ${shq(acmeFilePath)} ]`);
6223
+ if (!exists) {
6224
+ log.warn(`No acme.json found on ${host.name} yet. Traefik generates certificates upon the first incoming HTTPS request.`);
6225
+ allResults[host.name] = [];
6226
+ continue;
6227
+ }
6228
+ const rawJson = await host.capture(`cat ${shq(acmeFilePath)} 2>/dev/null || echo "{}"`, { allowFailure: true });
6229
+ let data = {};
6230
+ try {
6231
+ data = JSON.parse(rawJson);
6232
+ } catch {
6233
+ log.warn(`Failed to parse acme.json on ${host.name}.`);
6234
+ allResults[host.name] = [];
6235
+ continue;
6236
+ }
6237
+ const certs = [];
6238
+ for (const resolverKey of Object.keys(data)) {
6239
+ const resolverObj = data[resolverKey];
6240
+ const certList = Array.isArray(resolverObj?.Certificates) ? resolverObj.Certificates : [];
6241
+ for (const entry of certList) {
6242
+ const parsed = parseAcmeCert(entry);
6243
+ if (parsed)
6244
+ certs.push(parsed);
6245
+ }
6246
+ }
6247
+ allResults[host.name] = certs;
6248
+ if (ctx.values.json)
6249
+ continue;
6250
+ if (!certs.length) {
6251
+ log.info(`No certificates found in ${acmeFilePath} on ${host.name}.`);
6252
+ continue;
6253
+ }
6254
+ console.log("");
6255
+ console.log(` ${c.bold("Host:")} ${c.magenta(host.name)}`);
6256
+ console.log(` ${c.bold("SSL Resolver:")} Let's Encrypt (${cfg.proxy.email || "no contact email"})`);
6257
+ console.log("");
6258
+ const rows = [
6259
+ ["Domain", "SANs", "Issuer", "Expires", "Status"]
6260
+ ];
6261
+ for (const cert of certs) {
6262
+ let statusStr = "";
6263
+ if (cert.status === "active") {
6264
+ statusStr = c.green(`Active (${cert.daysRemaining}d left)`);
6265
+ } else if (cert.status === "expiring_soon") {
6266
+ statusStr = c.yellow(`Expiring soon (${cert.daysRemaining}d left)`);
6267
+ } else {
6268
+ statusStr = c.red(`EXPIRED`);
6269
+ }
6270
+ rows.push([
6271
+ c.bold(cert.mainDomain),
6272
+ cert.sans.length ? cert.sans.join(", ") : c.gray("\u2014"),
6273
+ cert.issuer,
6274
+ cert.validTo,
6275
+ statusStr
6276
+ ]);
6277
+ }
6278
+ const colWidths = [0, 0, 0, 0, 0];
6279
+ for (const row of rows) {
6280
+ for (let i = 0;i < row.length; i++) {
6281
+ const rawLen = row[i].replace(/\x1B\[\d+m/g, "").length;
6282
+ colWidths[i] = Math.max(colWidths[i], rawLen);
6283
+ }
6284
+ }
6285
+ for (let r = 0;r < rows.length; r++) {
6286
+ const row = rows[r];
6287
+ const line = row.map((val, idx) => {
6288
+ const rawLen = val.replace(/\x1B\[\d+m/g, "").length;
6289
+ const pad = " ".repeat(Math.max(0, colWidths[idx] - rawLen));
6290
+ return val + pad;
6291
+ }).join(" ");
6292
+ if (r === 0) {
6293
+ console.log(` ${c.gray(line)}`);
6294
+ console.log(` ${c.gray("-".repeat(line.length))}`);
6295
+ } else {
6296
+ console.log(` ${line}`);
6297
+ }
6298
+ }
6299
+ console.log("");
6300
+ }
6301
+ if (ctx.values.json) {
6302
+ console.log(JSON.stringify(allResults, null, 2));
6303
+ }
6304
+ }
6305
+ };
6306
+
6307
+ // src/commands/top.ts
6308
+ async function collectHostStats(host, cfg) {
6309
+ const isDocker = cfg.mode === "docker";
6310
+ const script = `
6311
+ echo "===UPTIME==="
6312
+ uptime || true
6313
+ echo "===MEM==="
6314
+ free -m 2>/dev/null | awk '/Mem:/ {printf "%dM / %dM (%.1f%%)", $3, $2, ($3/$2)*100}' || true
6315
+ echo ""
6316
+ echo "===DISK==="
6317
+ df -h /var/lib/epd 2>/dev/null | awk 'NR==2 {printf "%s / %s (%s)", $3, $2, $5}' || df -h / 2>/dev/null | awk 'NR==2 {printf "%s / %s (%s)", $3, $2, $5}' || true
6318
+ echo ""
6319
+ echo "===CONTAINERS==="
6320
+ ${isDocker ? "docker stats --no-stream --format '{{json .}}' 2>/dev/null || true" : "pm2 jlist 2>/dev/null || true"}
6321
+ `;
6322
+ const output = await host.capture(script, { allowFailure: true });
6323
+ const uptimeMatch = output.match(/===UPTIME===\s*([\s\S]*?)===MEM===/);
6324
+ const memMatch = output.match(/===MEM===\s*([\s\S]*?)===DISK===/);
6325
+ const diskMatch = output.match(/===DISK===\s*([\s\S]*?)===CONTAINERS===/);
6326
+ const containersRaw = output.split("===CONTAINERS===")[1] || "";
6327
+ const uptimeStr = (uptimeMatch?.[1] ?? "").trim();
6328
+ const ramStr = (memMatch?.[1] ?? "").trim();
6329
+ const diskStr = (diskMatch?.[1] ?? "").trim();
6330
+ let loadAvg = "";
6331
+ const loadMatch = uptimeStr.match(/load average[s]?:\s*([^\n]+)/i);
6332
+ if (loadMatch)
6333
+ loadAvg = loadMatch[1].trim();
6334
+ const containers = [];
6335
+ if (isDocker) {
6336
+ for (const line of containersRaw.split(`
6337
+ `)) {
6338
+ const trimmed = line.trim();
6339
+ if (!trimmed.startsWith("{"))
6340
+ continue;
6341
+ try {
6342
+ const item = JSON.parse(trimmed);
6343
+ if (item.Name && (item.Name.includes("epd") || item.Name.includes(cfg.name))) {
6344
+ containers.push(item);
6345
+ } else if (item.Name) {
6346
+ containers.push(item);
6347
+ }
6348
+ } catch {}
6349
+ }
6350
+ } else {
6351
+ try {
6352
+ const pm2List = JSON.parse(containersRaw);
6353
+ if (Array.isArray(pm2List)) {
6354
+ for (const proc of pm2List) {
6355
+ const memMb = proc.monit?.memory ? (proc.monit.memory / (1024 * 1024)).toFixed(1) + "MiB" : "0MiB";
6356
+ const cpu = proc.monit?.cpu ? `${proc.monit.cpu}%` : "0%";
6357
+ containers.push({
6358
+ Name: proc.name || "process",
6359
+ CPUPerc: cpu,
6360
+ MemUsage: memMb,
6361
+ MemPerc: "\u2014",
6362
+ NetIO: "\u2014",
6363
+ BlockIO: "\u2014",
6364
+ PIDs: String(proc.pid || "\u2014")
6365
+ });
6366
+ }
6367
+ }
6368
+ } catch {}
6369
+ }
6370
+ return {
6371
+ hostName: host.name,
6372
+ uptime: uptimeStr,
6373
+ loadAvg,
6374
+ ramSummary: ramStr || "unknown",
6375
+ diskSummary: diskStr || "unknown",
6376
+ containers
6377
+ };
6378
+ }
6379
+ function renderDashboard(statsList) {
6380
+ for (const stats of statsList) {
6381
+ console.log(c.bold(`
6382
+ \u2500\u2500 Host: ${c.magenta(stats.hostName)} \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`));
6383
+ console.log(` ${c.gray("Load:")} ${stats.loadAvg || "\u2014"} \u2502 ${c.gray("RAM:")} ${stats.ramSummary} \u2502 ${c.gray("Disk (/var/lib/epd):")} ${stats.diskSummary}`);
6384
+ console.log("");
6385
+ if (!stats.containers.length) {
6386
+ console.log(` ${c.gray("No running containers or processes found.")}
6387
+ `);
6388
+ continue;
6389
+ }
6390
+ const rows = [
6391
+ ["Container / Service", "CPU %", "Mem Usage / Limit", "Mem %", "Net I/O", "PIDs"]
6392
+ ];
6393
+ for (const cItem of stats.containers) {
6394
+ let cpuFormatted = cItem.CPUPerc;
6395
+ const cpuNum = parseFloat(cItem.CPUPerc);
6396
+ if (cpuNum > 80)
6397
+ cpuFormatted = c.red(cItem.CPUPerc);
6398
+ else if (cpuNum > 40)
6399
+ cpuFormatted = c.yellow(cItem.CPUPerc);
6400
+ else
6401
+ cpuFormatted = c.green(cItem.CPUPerc);
6402
+ rows.push([
6403
+ c.bold(cItem.Name),
6404
+ cpuFormatted,
6405
+ cItem.MemUsage,
6406
+ cItem.MemPerc,
6407
+ cItem.NetIO,
6408
+ cItem.PIDs
6409
+ ]);
6410
+ }
6411
+ const colWidths = [0, 0, 0, 0, 0, 0];
6412
+ for (const row of rows) {
6413
+ for (let i = 0;i < row.length; i++) {
6414
+ const rawLen = row[i].replace(/\x1B\[\d+m/g, "").length;
6415
+ colWidths[i] = Math.max(colWidths[i], rawLen);
6416
+ }
6417
+ }
6418
+ for (let r = 0;r < rows.length; r++) {
6419
+ const row = rows[r];
6420
+ const line = row.map((val, idx) => {
6421
+ const rawLen = val.replace(/\x1B\[\d+m/g, "").length;
6422
+ const pad = " ".repeat(Math.max(0, colWidths[idx] - rawLen));
6423
+ return val + pad;
6424
+ }).join(" ");
6425
+ if (r === 0) {
6426
+ console.log(` ${c.gray(line)}`);
6427
+ console.log(` ${c.gray("-".repeat(line.length))}`);
6428
+ } else {
6429
+ console.log(` ${line}`);
6430
+ }
6431
+ }
6432
+ console.log("");
6433
+ }
6434
+ }
6435
+ var top = {
6436
+ name: "top",
6437
+ aliases: ["stats"],
6438
+ summary: "Live multi-server CPU, memory, container and disk resource monitor",
6439
+ options: {
6440
+ host: { type: "string" },
6441
+ watch: { type: "boolean", short: "w" },
6442
+ once: { type: "boolean" }
6443
+ },
6444
+ help: () => `${c.bold("epd top")} \u2014 real-time server and container metrics monitor (aliased as epd stats)
6445
+
6446
+ Aggregates CPU %, memory consumption, network I/O, disk space, and load averages
6447
+ across all servers running this application.
6448
+
6449
+ Options
6450
+ --host <ip> Monitor only this specific host
6451
+ -w, --watch Stream metrics continuously (refreshes every 2s)
6452
+ --once Print a single snapshot and exit`,
6453
+ async run(ctx) {
6454
+ const loaded = ctx.load();
6455
+ const cfg = loaded.config;
6456
+ let hostNames = allHosts(cfg);
6457
+ if (ctx.values.host)
6458
+ hostNames = hostNames.filter((h) => h === ctx.values.host);
6459
+ if (!hostNames.length)
6460
+ throw new EpdError("No hosts found in configuration");
6461
+ const hosts = hostNames.map((h) => host(h, cfg.ssh));
6462
+ const shouldWatch = Boolean(ctx.values.watch) || interactive() && !ctx.values.once;
6463
+ const refresh = async () => {
6464
+ const statsList = await Promise.all(hosts.map((h) => collectHostStats(h, cfg)));
6465
+ if (shouldWatch)
6466
+ process.stdout.write("\x1Bc");
6467
+ renderDashboard(statsList);
6468
+ if (shouldWatch) {
6469
+ console.log(c.gray(` Streaming live metrics (2s interval). Press Ctrl-C to exit.`));
6470
+ }
6471
+ };
6472
+ await refresh();
6473
+ if (shouldWatch) {
6474
+ return new Promise((resolve) => {
6475
+ const interval = setInterval(async () => {
6476
+ try {
6477
+ await refresh();
6478
+ } catch {
6479
+ clearInterval(interval);
6480
+ resolve();
6481
+ }
6482
+ }, 2000);
6483
+ process.on("SIGINT", () => {
6484
+ clearInterval(interval);
6485
+ console.log("");
6486
+ resolve();
6487
+ });
6488
+ });
6489
+ }
6490
+ }
6491
+ };
6492
+
6493
+ // src/commands/backup.ts
6494
+ import { createWriteStream, mkdirSync as mkdirSync5, statSync } from "fs";
6495
+ import { dirname as dirname3, join as join8, resolve as resolve2 } from "path";
6496
+ function detectAccessoryType(decl, cfg) {
6497
+ const name = decl.name;
6498
+ const img = (decl.image || "").toLowerCase();
6499
+ const hostName = decl.host || cfg.services[0]?.hosts[0] || "localhost";
6500
+ const containerName = accessoryContainer(cfg.name, name);
6501
+ const env = { ...decl.env };
6502
+ if (img.includes("postgres") || img.includes("postgis") || img.includes("timescale")) {
6503
+ return {
6504
+ name,
6505
+ decl,
6506
+ hostName,
6507
+ type: "postgres",
6508
+ containerName,
6509
+ dbUser: env.POSTGRES_USER || "postgres",
6510
+ dbName: env.POSTGRES_DB || cfg.name
6511
+ };
6512
+ }
6513
+ if (img.includes("mysql") || img.includes("mariadb")) {
6514
+ return {
6515
+ name,
6516
+ decl,
6517
+ hostName,
6518
+ type: "mysql",
6519
+ containerName,
6520
+ dbUser: env.MYSQL_USER || "root",
6521
+ dbPass: env.MYSQL_ROOT_PASSWORD || env.MYSQL_PASSWORD,
6522
+ dbName: env.MYSQL_DATABASE || cfg.name
6523
+ };
6524
+ }
6525
+ if (img.includes("mongo")) {
6526
+ return {
6527
+ name,
6528
+ decl,
6529
+ hostName,
6530
+ type: "mongo",
6531
+ containerName,
6532
+ dbName: cfg.name
6533
+ };
6534
+ }
6535
+ let volumeDir;
6536
+ for (const v of decl.volumes) {
6537
+ const hostSide = v.split(":")[0];
6538
+ if (hostSide && hostSide.startsWith("/")) {
6539
+ volumeDir = hostSide;
6540
+ break;
6541
+ }
6542
+ }
6543
+ return {
6544
+ name,
6545
+ decl,
6546
+ hostName,
6547
+ type: "volume",
6548
+ containerName,
6549
+ volumeDir
6550
+ };
6551
+ }
6552
+ var backup = {
6553
+ name: "backup",
6554
+ summary: "Back up databases and accessory volumes to compressed local archives",
6555
+ options: {
6556
+ output: { type: "string", short: "o" },
6557
+ host: { type: "string" }
6558
+ },
6559
+ help: () => `${c.bold("epd backup [accessory]")} \u2014 create compressed database or volume backups
6560
+
6561
+ Automatically inspects the accessory image (PostgreSQL, MySQL, MariaDB, Mongo, or generic volumes)
6562
+ and streams a compressed snapshot directly to your local ./backups directory.
6563
+
6564
+ Options
6565
+ -o, --output <path> Custom output path or destination directory
6566
+ --host <ip> Host running the accessory`,
6567
+ async run(ctx) {
6568
+ const loaded = ctx.load();
6569
+ const cfg = loaded.config;
6570
+ const requestedName = ctx.positionals[0];
6571
+ const accessories = cfg.accessories;
6572
+ if (!accessories.length) {
6573
+ throw new EpdError(`No accessories configured in epd.yml under "accessories:".`);
6574
+ }
6575
+ let targets = [];
6576
+ if (requestedName) {
6577
+ const found = accessories.find((a) => a.name === requestedName);
6578
+ if (!found) {
6579
+ throw new EpdError(`Accessory "${requestedName}" not found. Configured: ${accessories.map((a) => a.name).join(", ")}`);
6580
+ }
6581
+ targets = [detectAccessoryType(found, cfg)];
6582
+ } else {
6583
+ targets = accessories.map((a) => detectAccessoryType(a, cfg));
6584
+ }
6585
+ const outBaseDir = resolve2(process.cwd(), "backups");
6586
+ mkdirSync5(outBaseDir, { recursive: true });
6587
+ for (const target of targets) {
6588
+ const host2 = host(target.hostName, cfg.ssh);
6589
+ const isRunning = await host2.test(`docker ps -q -f name=${shq(`^${target.containerName}$`)} | grep -q .`);
6590
+ if (!isRunning) {
6591
+ log.warn(`Container ${c.bold(target.containerName)} is not currently running on ${host2.name}. Skipping.`);
6592
+ continue;
6593
+ }
6594
+ const timestamp = new Date().toISOString().replace(/[:.]/g, "-").replace("T", "_").slice(0, 19);
6595
+ const ext = target.type === "volume" ? "tar.gz" : "sql.gz";
6596
+ const filename = `${cfg.name}-${target.name}-${timestamp}.${ext}`;
6597
+ const localFile = ctx.values.output ? resolve2(String(ctx.values.output)) : join8(outBaseDir, filename);
6598
+ mkdirSync5(dirname3(localFile), { recursive: true });
6599
+ let dumpCmd = "";
6600
+ if (target.type === "postgres") {
6601
+ dumpCmd = `docker exec ${shq(target.containerName)} pg_dump -U ${shq(target.dbUser)} ${shq(target.dbName)} | gzip -9`;
6602
+ } else if (target.type === "mysql") {
6603
+ const passFlag = target.dbPass ? `-p${shq(target.dbPass)}` : "";
6604
+ dumpCmd = `docker exec ${shq(target.containerName)} mysqldump -u ${shq(target.dbUser)} ${passFlag} ${shq(target.dbName)} | gzip -9`;
6605
+ } else if (target.type === "mongo") {
6606
+ dumpCmd = `docker exec ${shq(target.containerName)} mongodump --archive --gzip`;
6607
+ } else {
6608
+ if (!target.volumeDir) {
6609
+ log.warn(`No host volume path found for accessory "${target.name}". Skipping.`);
6610
+ continue;
6611
+ }
6612
+ dumpCmd = `tar -czf - -C ${shq(target.volumeDir)} .`;
6613
+ }
6614
+ log.step(`Streaming ${c.bold(target.type)} backup of ${c.magenta(target.name)} from ${host2.name}...`);
6615
+ const t0 = Date.now();
6616
+ const sshArgs = [...host2.sshOptions(), host2.target, dumpCmd];
6617
+ const writeStream = createWriteStream(localFile);
6618
+ await new Promise((res, rej) => {
6619
+ const proc = typeof process.isBun !== "undefined" ? Bun.spawn(["ssh", ...sshArgs], { stdout: "pipe", stderr: "pipe" }) : __require("child_process").spawn("ssh", sshArgs, { stdio: ["ignore", "pipe", "pipe"] });
6620
+ const stream = proc.stdout;
6621
+ stream.pipe(writeStream);
6622
+ writeStream.on("finish", () => res());
6623
+ writeStream.on("error", rej);
6624
+ if (proc.exited) {
6625
+ proc.exited.then((code) => {
6626
+ if (code !== 0)
6627
+ rej(new EpdError(`SSH backup process exited with code ${code}`));
6628
+ });
6629
+ } else {
6630
+ proc.on("close", (code) => {
6631
+ if (code !== 0)
6632
+ rej(new EpdError(`SSH backup process exited with code ${code}`));
6633
+ });
6634
+ }
6635
+ });
6636
+ const stats = statSync(localFile);
6637
+ const sizeMb = (stats.size / (1024 * 1024)).toFixed(2);
6638
+ const elapsed = dur(Date.now() - t0);
6639
+ log.ok(`Backed up ${c.bold(target.name)} \u2192 ${c.cyan(localFile)} (${sizeMb} MB in ${elapsed})`);
6640
+ }
6641
+ }
6642
+ };
6643
+
6644
+ // src/commands/restore.ts
6645
+ import { createReadStream, existsSync as existsSync7 } from "fs";
6646
+ import { basename as basename2, resolve as resolve3 } from "path";
6647
+ var restore = {
6648
+ name: "restore",
6649
+ summary: "Restore a database or volume backup into a running accessory",
6650
+ options: {
6651
+ accessory: { type: "string", short: "a" },
6652
+ yes: { type: "boolean", short: "y" }
6653
+ },
6654
+ help: () => `${c.bold("epd restore <backup-file>")} \u2014 restore a database or volume backup
6655
+
6656
+ Pipes a local .sql.gz or .tar.gz archive directly into a live accessory container.
6657
+
6658
+ Options
6659
+ -a, --accessory <name> Target accessory name (default: auto-detected from filename)
6660
+ -y, --yes Skip confirmation prompt`,
6661
+ async run(ctx) {
6662
+ const backupPath = ctx.positionals[0];
6663
+ if (!backupPath)
6664
+ throw new EpdError("Please provide a path to the backup file to restore.");
6665
+ const absPath = resolve3(backupPath);
6666
+ if (!existsSync7(absPath))
6667
+ throw new EpdError(`Backup file not found: ${absPath}`);
6668
+ const loaded = ctx.load();
6669
+ const cfg = loaded.config;
6670
+ const fileBase = basename2(absPath);
6671
+ const accessories = cfg.accessories;
6672
+ if (!accessories.length)
6673
+ throw new EpdError("No accessories configured in epd.yml.");
6674
+ let targetAccessoryName = ctx.values.accessory;
6675
+ if (!targetAccessoryName) {
6676
+ for (const a of accessories) {
6677
+ if (fileBase.includes(a.name)) {
6678
+ targetAccessoryName = a.name;
6679
+ break;
6680
+ }
6681
+ }
6682
+ }
6683
+ if (!targetAccessoryName && accessories.length === 1) {
6684
+ targetAccessoryName = accessories[0].name;
6685
+ }
6686
+ if (!targetAccessoryName) {
6687
+ throw new EpdError(`Could not auto-detect target accessory from filename "${fileBase}". Specify with --accessory <name>.`);
6688
+ }
6689
+ const decl = accessories.find((a) => a.name === targetAccessoryName);
6690
+ if (!decl) {
6691
+ throw new EpdError(`Accessory "${targetAccessoryName}" not found in configuration.`);
6692
+ }
6693
+ const hostName = decl.host || cfg.services[0]?.hosts[0] || "localhost";
6694
+ const host2 = host(hostName, cfg.ssh);
6695
+ const containerName = accessoryContainer(cfg.name, targetAccessoryName);
6696
+ const isRunning = await host2.test(`docker ps -q -f name=${shq(`^${containerName}$`)} | grep -q .`);
6697
+ if (!isRunning) {
6698
+ throw new EpdError(`Accessory container ${containerName} is not running on ${host2.name}.`);
6699
+ }
6700
+ if (!ctx.values.yes) {
6701
+ log.warn(`Restoring will overwrite existing data in accessory ${c.bold(targetAccessoryName)} on ${c.magenta(host2.name)}!`);
6702
+ const ok = await confirm(`Are you sure you want to restore ${c.bold(fileBase)}?`, false);
6703
+ if (!ok) {
6704
+ log.info("Restore aborted.");
6705
+ return;
6706
+ }
6707
+ }
6708
+ const img = (decl.image || "").toLowerCase();
6709
+ const env = { ...decl.env };
6710
+ let restoreCmd = "";
6711
+ if (img.includes("postgres") || img.includes("postgis") || img.includes("timescale")) {
6712
+ const user = env.POSTGRES_USER || "postgres";
6713
+ const db = env.POSTGRES_DB || cfg.name;
6714
+ restoreCmd = `gunzip -c | docker exec -i ${shq(containerName)} psql -U ${shq(user)} ${shq(db)}`;
6715
+ } else if (img.includes("mysql") || img.includes("mariadb")) {
6716
+ const user = env.MYSQL_USER || "root";
6717
+ const pass = env.MYSQL_ROOT_PASSWORD || env.MYSQL_PASSWORD;
6718
+ const passFlag = pass ? `-p${shq(pass)}` : "";
6719
+ const db = env.MYSQL_DATABASE || cfg.name;
6720
+ restoreCmd = `gunzip -c | docker exec -i ${shq(containerName)} mysql -u ${shq(user)} ${passFlag} ${shq(db)}`;
6721
+ } else if (img.includes("mongo")) {
6722
+ restoreCmd = `docker exec -i ${shq(containerName)} mongorestore --archive --gzip`;
6723
+ } else {
6724
+ let volumeDir;
6725
+ for (const v of decl.volumes) {
6726
+ const hostSide = v.split(":")[0];
6727
+ if (hostSide && hostSide.startsWith("/")) {
6728
+ volumeDir = hostSide;
6729
+ break;
6730
+ }
6731
+ }
6732
+ if (!volumeDir)
6733
+ throw new EpdError(`No host volume path configured for accessory "${targetAccessoryName}".`);
6734
+ restoreCmd = `tar -xzf - -C ${shq(volumeDir)}`;
6735
+ }
6736
+ log.step(`Streaming restore into ${c.bold(targetAccessoryName)} on ${host2.name}...`);
6737
+ const t0 = Date.now();
6738
+ const sshArgs = [...host2.sshOptions(), host2.target, restoreCmd];
6739
+ const readStream = createReadStream(absPath);
6740
+ await new Promise((res, rej) => {
6741
+ const proc = typeof process.isBun !== "undefined" ? Bun.spawn(["ssh", ...sshArgs], { stdin: "pipe", stdout: "inherit", stderr: "inherit" }) : __require("child_process").spawn("ssh", sshArgs, { stdio: ["pipe", "inherit", "inherit"] });
6742
+ const stdinStream = proc.stdin;
6743
+ readStream.pipe(stdinStream);
6744
+ readStream.on("error", rej);
6745
+ if (proc.exited) {
6746
+ proc.exited.then((code) => {
6747
+ if (code !== 0)
6748
+ rej(new EpdError(`Restore command exited with code ${code}`));
6749
+ else
6750
+ res();
6751
+ });
6752
+ } else {
6753
+ proc.on("close", (code) => {
6754
+ if (code !== 0)
6755
+ rej(new EpdError(`Restore command exited with code ${code}`));
6756
+ else
6757
+ res();
6758
+ });
6759
+ }
6760
+ });
6761
+ const elapsed = dur(Date.now() - t0);
6762
+ log.ok(`Successfully restored ${c.bold(fileBase)} into ${c.bold(targetAccessoryName)} (${elapsed})!`);
6763
+ }
6764
+ };
6765
+
5838
6766
  // src/commands/index.ts
5839
6767
  var commands = [
5840
6768
  init,
@@ -5855,7 +6783,12 @@ var commands = [
5855
6783
  dns3,
5856
6784
  hetzner,
5857
6785
  update,
5858
- auth
6786
+ auth,
6787
+ maintenance,
6788
+ ssl,
6789
+ top,
6790
+ backup,
6791
+ restore
5859
6792
  ];
5860
6793
 
5861
6794
  // src/cli.ts
@@ -26,7 +26,7 @@ export default defineConfig({
26
26
  ],
27
27
  },
28
28
  {
29
- text: "v0.4.0",
29
+ text: "v0.5.0",
30
30
  items: [
31
31
  { text: "Releases & Changelog", link: "https://github.com/FabioPlunser/epd/releases" },
32
32
  { text: "NPM Package", link: "https://www.npmjs.com/package/@fabioplunser/epd" },
@@ -184,6 +184,7 @@ epd proxy status # View Traefik container status
184
184
  epd proxy logs -f # Tail live Traefik access & error logs
185
185
  epd proxy routes # View rendered dynamic routing configuration
186
186
  epd proxy reboot # Restart Traefik proxy
187
+ epd proxy dashboard # Open secure SSH tunnel to Traefik web UI & launch browser
187
188
  ```
188
189
 
189
190
  ---
@@ -236,3 +237,63 @@ epd remove
236
237
  epd remove -y # Non-interactive confirmation
237
238
  epd remove --keep-data # Leave persistent volume data on disk
238
239
  ```
240
+
241
+ ---
242
+
243
+ ## `epd maintenance`
244
+
245
+ Toggle or inspect zero-downtime maintenance mode for this application. Injects an instant Traefik routing override that presents a responsive 503 Maintenance page to all public visitors without stopping backend containers or dropping TLS certificates.
246
+
247
+ ```bash
248
+ epd maintenance status # Check if maintenance mode is active
249
+ epd maintenance on # Enable maintenance mode
250
+ epd maintenance on -m "Migrating database. Back at 15:00 UTC."
251
+ epd maintenance off # Disable maintenance mode and restore traffic
252
+ ```
253
+
254
+ ---
255
+
256
+ ## `epd ssl`
257
+
258
+ Inspect and verify Let's Encrypt SSL/TLS certificates managed by Traefik across your servers (aliased as `epd certs`).
259
+
260
+ ```bash
261
+ epd ssl # Display table of domains, SANs, issuers, and days remaining
262
+ epd ssl --json # Output certificate metadata as JSON
263
+ epd ssl --host 203.0.113.10 # Query a specific host
264
+ ```
265
+
266
+ ---
267
+
268
+ ## `epd top`
269
+
270
+ Real-time multi-server metrics monitor (aliased as `epd stats`). Displays CPU %, memory consumption, container processes, network I/O, disk usage, and host load averages across all servers.
271
+
272
+ ```bash
273
+ epd top # Launch interactive streaming metrics dashboard (2s refresh)
274
+ epd top --once # Print a single metrics snapshot and exit
275
+ epd top --host 203.0.113.10 # Monitor a specific server
276
+ ```
277
+
278
+ ---
279
+
280
+ ## `epd backup`
281
+
282
+ Create compressed database and volume backups from running accessories (PostgreSQL, MySQL, MariaDB, MongoDB, or generic persistent volumes).
283
+
284
+ ```bash
285
+ epd backup # Back up all configured accessories
286
+ epd backup db # Back up a specific database accessory
287
+ epd backup db -o ./my-backup.sql.gz # Custom local output file path
288
+ ```
289
+
290
+ ---
291
+
292
+ ## `epd restore`
293
+
294
+ Restore a database or volume snapshot into a live running accessory.
295
+
296
+ ```bash
297
+ epd restore ./backups/myapp-db-2026-09-07.sql.gz
298
+ epd restore ./backups/myapp-db.sql.gz --accessory db -y # Skip confirmation prompt
299
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabioplunser/epd",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Easy Project Deployer — deploy any project to one or many servers with Docker or PM2, fronted by Traefik.",
5
5
  "type": "module",
6
6
  "author": "Fabio Plünser",