mirror of
https://github.com/tale/headplane.git
synced 2026-08-29 00:17:13 +00:00
Merge remote-tracking branch 'origin/main' into next
This commit is contained in:
@@ -61,14 +61,37 @@ export default class ProcIntegration extends Integration<T> {
|
|||||||
|
|
||||||
log.debug('config', 'Found Headscale processes: %o', pids);
|
log.debug('config', 'Found Headscale processes: %o', pids);
|
||||||
if (pids.length > 1) {
|
if (pids.length > 1) {
|
||||||
log.error(
|
log.warn(
|
||||||
'config',
|
'config',
|
||||||
'Found %d Headscale processes: %s',
|
'Found %d Headscale processes: %s',
|
||||||
pids.length,
|
pids.length,
|
||||||
pids.join(', '),
|
pids.join(', '),
|
||||||
);
|
);
|
||||||
return false;
|
|
||||||
}
|
log.debug('config', 'Checking if any of them have Parent PID = 1, assuming thats the correct PID');
|
||||||
|
const ppidRegex = /(?:PPid:\s)(\d+)(?:\n?)/;
|
||||||
|
for (const pid of pids) {
|
||||||
|
const pidStatusPath = join('/proc', pid.toString(), 'status');
|
||||||
|
try {
|
||||||
|
log.debug('config', 'Reading %s', pidStatusPath);
|
||||||
|
const pidData = await readFile(pidStatusPath, 'utf8');
|
||||||
|
const ppidResult = pidData.match(ppidRegex);
|
||||||
|
|
||||||
|
if (ppidResult !== null) {
|
||||||
|
const potentialPPid = Number.parseInt(ppidResult[1], 10);
|
||||||
|
if (potentialPPid === 1) {
|
||||||
|
this.pid = pid;
|
||||||
|
log.info('config', 'Found potential Headscale process with PID: %d based on Parent PID = 1', this.pid);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
log.error('config', 'Failed to read %s: %s', pidStatusPath, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (pids.length === 0) {
|
if (pids.length === 0) {
|
||||||
log.error('config', 'Could not find Headscale process');
|
log.error('config', 'Could not find Headscale process');
|
||||||
|
|||||||
Generated
+3
-3
@@ -40,11 +40,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1749871736,
|
"lastModified": 1750386251,
|
||||||
"narHash": "sha256-K9yBph93OLTNw02Q6e9CYFGrUhvEXnh45vrZqIRWfvQ=",
|
"narHash": "sha256-1ovgdmuDYVo5OUC5NzdF+V4zx2uT8RtsgZahxidBTyw=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "6afe187897bef7933475e6af374c893f4c84a293",
|
"rev": "076e8c6678d8c54204abcb4b1b14c366835a58bb",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
Reference in New Issue
Block a user