@patiom/daemon 0.0.6 → 0.0.7

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 +27 -19
  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.7";
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]
@@ -626,7 +625,7 @@ const executeDeploy = async (name, releaseId, zipBuffer, domains, sslipDomain, i
626
625
  await install(releaseDir, log);
627
626
  await log("Detecting start script...");
628
627
  const startScript = await getStartScript(releaseDir);
629
- await log(`Using start script: pnpm run ${startScript}`);
628
+ await log(`Using start script: npm run ${startScript}`);
630
629
  await log("Writing systemd unit file...");
631
630
  await writeUnitFile(name, startScript);
632
631
  await log("Allocating ports...");
@@ -640,7 +639,11 @@ const executeDeploy = async (name, releaseId, zipBuffer, domains, sslipDomain, i
640
639
  const sslip = await buildSslipDomain(name);
641
640
  if (sslip) allDomains.push(sslip);
642
641
  }
643
- if (allDomains.length > 0) await updateRpxyConfig(name, allDomains, ports, log);
642
+ if (allDomains.length > 0) {
643
+ await updateRpxyConfig(name, allDomains, ports, log);
644
+ log("Restarting rpxy...");
645
+ await restart("rpxy");
646
+ }
644
647
  await log(`Deployment complete!`);
645
648
  await log(`Domains: ${allDomains.join(", ") || "none"}`);
646
649
  await log(`Ports: ${ports.join(", ")}`);
@@ -1165,8 +1168,8 @@ program.command("upgrade").description("Update the daemon package and restart th
1165
1168
  consola.info(`Current version: ${version}`);
1166
1169
  let latest = null;
1167
1170
  try {
1168
- const { stdout } = await execa("pnpm", [
1169
- "info",
1171
+ const { stdout } = await execa("npm", [
1172
+ "view",
1170
1173
  "@patiom/daemon",
1171
1174
  "version"
1172
1175
  ]);
@@ -1180,11 +1183,16 @@ program.command("upgrade").description("Update the daemon package and restart th
1180
1183
  }
1181
1184
  if (latest) consola.info(`Latest version: ${latest}`);
1182
1185
  consola.start("Updating @patiom/daemon...");
1183
- await execa("pnpm", [
1184
- "update",
1186
+ await execa("npm", [
1187
+ "uninstall",
1185
1188
  "-g",
1186
1189
  "@patiom/daemon"
1187
1190
  ]);
1191
+ await execa("npm", [
1192
+ "install",
1193
+ "-g",
1194
+ "@patiom/daemon@latest"
1195
+ ]);
1188
1196
  const pkgPath = path.resolve(import.meta.dirname, "..", "package.json");
1189
1197
  const newVersion = JSON.parse(readFileSync(pkgPath, "utf-8")).version;
1190
1198
  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.7",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "patiom-server": "dist/index.js"