mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
fix(server): parse pid start times in stable locale
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, test } from "vitest";
|
||||
@@ -55,7 +55,6 @@ describe("pid-lock ownership", () => {
|
||||
const replacementOwnerPid = process.pid + 10_000;
|
||||
|
||||
try {
|
||||
await mkdir(paseoHome, { recursive: true });
|
||||
await writeFile(
|
||||
join(paseoHome, "paseo.pid"),
|
||||
JSON.stringify({
|
||||
|
||||
@@ -37,6 +37,7 @@ export class PidLockError extends Error {
|
||||
|
||||
const PROCESS_START_SKEW_TOLERANCE_MS = 60_000;
|
||||
const PROCESS_LOCK_ACQUIRE_TOLERANCE_MS = 5 * 60_000;
|
||||
const POSIX_PROCESS_TIME_ENV = { ...process.env, LC_ALL: "C", LANG: "C" };
|
||||
let cachedClockTicksPerSecond: number | null = null;
|
||||
|
||||
function isPidRunning(pid: number): boolean {
|
||||
@@ -96,6 +97,7 @@ function readPsProcessStartedAtMs(pid: number): number | null {
|
||||
try {
|
||||
const output = execFileSync("ps", ["-p", String(pid), "-o", "lstart="], {
|
||||
encoding: "utf8",
|
||||
env: POSIX_PROCESS_TIME_ENV,
|
||||
timeout: 1000,
|
||||
}).trim();
|
||||
const parsed = Date.parse(output);
|
||||
|
||||
Reference in New Issue
Block a user