@patiom/daemon 0.0.6 → 0.0.8

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/dist/index.js +30 -20
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ import { parse, stringify } from "smol-toml";
16
16
  import dotenv from "dotenv";
17
17
  import { spawn } from "node:child_process";
18
18
  //#region package.json
19
- var version = "0.0.6";
19
+ var version = "0.0.8";
20
20
  //#endregion
21
21
  //#region src/config.ts
22
22
  const PATIOM_ROOT = "/var/lib/patiom";
@@ -193,23 +193,19 @@ const getCurrentRelease = async (appName) => {
193
193
  }
194
194
  };
195
195
  //#endregion
196
- //#region src/core/pnpm.ts
197
- const hasLockfile = async (releaseDir) => {
196
+ //#region src/core/pm.ts
197
+ const hasPackageLock = async (releaseDir) => {
198
198
  try {
199
- await fs.access(path.join(releaseDir, "pnpm-lock.yaml"));
199
+ await fs.access(path.join(releaseDir, "package-lock.json"));
200
200
  return true;
201
201
  } catch {
202
202
  return false;
203
203
  }
204
204
  };
205
205
  const install = async (releaseDir, log) => {
206
- const args = await hasLockfile(releaseDir) ? [
207
- "install",
208
- "--frozen-lockfile",
209
- "--prod"
210
- ] : ["install", "--prod"];
211
- log(`Running: pnpm ${args.join(" ")}`);
212
- const proc = execa("pnpm", args, {
206
+ const args = await hasPackageLock(releaseDir) ? ["ci", "--omit=dev"] : ["install", "--omit=dev"];
207
+ log(`Running: npm ${args.join(" ")}`);
208
+ const proc = execa("npm", args, {
213
209
  cwd: releaseDir,
214
210
  stdout: "pipe",
215
211
  stderr: "pipe"
@@ -400,15 +396,16 @@ const ensureStorageDir = async (appName, storageFolder, log) => {
400
396
  const appServiceTemplate = ({ nodeBinPath, startScript }) => `[Unit]
401
397
  Description=Patiom App: %p (port %i)
402
398
  After=network.target
399
+ StartLimitIntervalSec=0
403
400
 
404
401
  [Service]
405
402
  Type=exec
406
403
  WorkingDirectory=${PATIOM_ROOT}/apps/%p/current
407
- ExecStart=/usr/local/bin/pnpm run ${startScript}
404
+ ExecStart=npm run ${startScript}
408
405
  Restart=always
406
+ RestartSec=5
409
407
  EnvironmentFile=${PATIOM_ROOT}/apps/%p/shared/.env
410
408
  Environment=PORT=%i
411
- Environment=npm_config_verifyDepsBeforeRun=false
412
409
  Environment=PATH=${nodeBinPath}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
413
410
 
414
411
  DynamicUser=yes
@@ -422,10 +419,12 @@ WantedBy=multi-user.target
422
419
  const rpxyServiceTemplate = ({ rpxyBinPath }) => `[Unit]
423
420
  Description=rpxy Reverse Proxy
424
421
  After=network.target
422
+ StartLimitIntervalSec=0
425
423
 
426
424
  [Service]
427
425
  ExecStart=${rpxyBinPath} --config /etc/rpxy/config.toml
428
426
  Restart=always
427
+ RestartSec=5
429
428
  LimitNOFILE=65536
430
429
 
431
430
  [Install]
@@ -434,11 +433,13 @@ WantedBy=multi-user.target
434
433
  const daemonServiceTemplate = ({ nodeBinPath, port }) => `[Unit]
435
434
  Description=Patiom Daemon
436
435
  After=network.target
436
+ StartLimitIntervalSec=0
437
437
 
438
438
  [Service]
439
439
  Type=exec
440
- ExecStart=/usr/local/bin/patiom-server serve
440
+ ExecStart=${nodeBinPath}/patiom-server serve
441
441
  Restart=always
442
+ RestartSec=5
442
443
  Environment=PORT=${port}
443
444
  Environment=PATH=${nodeBinPath}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
444
445
 
@@ -626,7 +627,7 @@ const executeDeploy = async (name, releaseId, zipBuffer, domains, sslipDomain, i
626
627
  await install(releaseDir, log);
627
628
  await log("Detecting start script...");
628
629
  const startScript = await getStartScript(releaseDir);
629
- await log(`Using start script: pnpm run ${startScript}`);
630
+ await log(`Using start script: npm run ${startScript}`);
630
631
  await log("Writing systemd unit file...");
631
632
  await writeUnitFile(name, startScript);
632
633
  await log("Allocating ports...");
@@ -640,7 +641,11 @@ const executeDeploy = async (name, releaseId, zipBuffer, domains, sslipDomain, i
640
641
  const sslip = await buildSslipDomain(name);
641
642
  if (sslip) allDomains.push(sslip);
642
643
  }
643
- if (allDomains.length > 0) await updateRpxyConfig(name, allDomains, ports, log);
644
+ if (allDomains.length > 0) {
645
+ await updateRpxyConfig(name, allDomains, ports, log);
646
+ log("Restarting rpxy...");
647
+ await restart("rpxy");
648
+ }
644
649
  await log(`Deployment complete!`);
645
650
  await log(`Domains: ${allDomains.join(", ") || "none"}`);
646
651
  await log(`Ports: ${ports.join(", ")}`);
@@ -1165,8 +1170,8 @@ program.command("upgrade").description("Update the daemon package and restart th
1165
1170
  consola.info(`Current version: ${version}`);
1166
1171
  let latest = null;
1167
1172
  try {
1168
- const { stdout } = await execa("pnpm", [
1169
- "info",
1173
+ const { stdout } = await execa("npm", [
1174
+ "view",
1170
1175
  "@patiom/daemon",
1171
1176
  "version"
1172
1177
  ]);
@@ -1180,11 +1185,16 @@ program.command("upgrade").description("Update the daemon package and restart th
1180
1185
  }
1181
1186
  if (latest) consola.info(`Latest version: ${latest}`);
1182
1187
  consola.start("Updating @patiom/daemon...");
1183
- await execa("pnpm", [
1184
- "update",
1188
+ await execa("npm", [
1189
+ "uninstall",
1185
1190
  "-g",
1186
1191
  "@patiom/daemon"
1187
1192
  ]);
1193
+ await execa("npm", [
1194
+ "install",
1195
+ "-g",
1196
+ "@patiom/daemon@latest"
1197
+ ]);
1188
1198
  const pkgPath = path.resolve(import.meta.dirname, "..", "package.json");
1189
1199
  const newVersion = JSON.parse(readFileSync(pkgPath, "utf-8")).version;
1190
1200
  consola.success(`Updated to ${newVersion}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patiom/daemon",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "patiom-server": "dist/index.js"