@patiom/daemon 0.0.5 → 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.
- package/dist/index.js +27 -18
- 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.
|
|
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/
|
|
197
|
-
const
|
|
196
|
+
//#region src/core/pm.ts
|
|
197
|
+
const hasPackageLock = async (releaseDir) => {
|
|
198
198
|
try {
|
|
199
|
-
await fs.access(path.join(releaseDir, "
|
|
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
|
|
207
|
-
|
|
208
|
-
|
|
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,12 +396,14 @@ 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
|
|
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
409
|
Environment=PATH=${nodeBinPath}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
@@ -421,10 +419,12 @@ WantedBy=multi-user.target
|
|
|
421
419
|
const rpxyServiceTemplate = ({ rpxyBinPath }) => `[Unit]
|
|
422
420
|
Description=rpxy Reverse Proxy
|
|
423
421
|
After=network.target
|
|
422
|
+
StartLimitIntervalSec=0
|
|
424
423
|
|
|
425
424
|
[Service]
|
|
426
425
|
ExecStart=${rpxyBinPath} --config /etc/rpxy/config.toml
|
|
427
426
|
Restart=always
|
|
427
|
+
RestartSec=5
|
|
428
428
|
LimitNOFILE=65536
|
|
429
429
|
|
|
430
430
|
[Install]
|
|
@@ -625,7 +625,7 @@ const executeDeploy = async (name, releaseId, zipBuffer, domains, sslipDomain, i
|
|
|
625
625
|
await install(releaseDir, log);
|
|
626
626
|
await log("Detecting start script...");
|
|
627
627
|
const startScript = await getStartScript(releaseDir);
|
|
628
|
-
await log(`Using start script:
|
|
628
|
+
await log(`Using start script: npm run ${startScript}`);
|
|
629
629
|
await log("Writing systemd unit file...");
|
|
630
630
|
await writeUnitFile(name, startScript);
|
|
631
631
|
await log("Allocating ports...");
|
|
@@ -639,7 +639,11 @@ const executeDeploy = async (name, releaseId, zipBuffer, domains, sslipDomain, i
|
|
|
639
639
|
const sslip = await buildSslipDomain(name);
|
|
640
640
|
if (sslip) allDomains.push(sslip);
|
|
641
641
|
}
|
|
642
|
-
if (allDomains.length > 0)
|
|
642
|
+
if (allDomains.length > 0) {
|
|
643
|
+
await updateRpxyConfig(name, allDomains, ports, log);
|
|
644
|
+
log("Restarting rpxy...");
|
|
645
|
+
await restart("rpxy");
|
|
646
|
+
}
|
|
643
647
|
await log(`Deployment complete!`);
|
|
644
648
|
await log(`Domains: ${allDomains.join(", ") || "none"}`);
|
|
645
649
|
await log(`Ports: ${ports.join(", ")}`);
|
|
@@ -1164,8 +1168,8 @@ program.command("upgrade").description("Update the daemon package and restart th
|
|
|
1164
1168
|
consola.info(`Current version: ${version}`);
|
|
1165
1169
|
let latest = null;
|
|
1166
1170
|
try {
|
|
1167
|
-
const { stdout } = await execa("
|
|
1168
|
-
"
|
|
1171
|
+
const { stdout } = await execa("npm", [
|
|
1172
|
+
"view",
|
|
1169
1173
|
"@patiom/daemon",
|
|
1170
1174
|
"version"
|
|
1171
1175
|
]);
|
|
@@ -1179,11 +1183,16 @@ program.command("upgrade").description("Update the daemon package and restart th
|
|
|
1179
1183
|
}
|
|
1180
1184
|
if (latest) consola.info(`Latest version: ${latest}`);
|
|
1181
1185
|
consola.start("Updating @patiom/daemon...");
|
|
1182
|
-
await execa("
|
|
1183
|
-
"
|
|
1186
|
+
await execa("npm", [
|
|
1187
|
+
"uninstall",
|
|
1184
1188
|
"-g",
|
|
1185
1189
|
"@patiom/daemon"
|
|
1186
1190
|
]);
|
|
1191
|
+
await execa("npm", [
|
|
1192
|
+
"install",
|
|
1193
|
+
"-g",
|
|
1194
|
+
"@patiom/daemon@latest"
|
|
1195
|
+
]);
|
|
1187
1196
|
const pkgPath = path.resolve(import.meta.dirname, "..", "package.json");
|
|
1188
1197
|
const newVersion = JSON.parse(readFileSync(pkgPath, "utf-8")).version;
|
|
1189
1198
|
consola.success(`Updated to ${newVersion}`);
|