chore: tighten pid logic
This commit is contained in:
parent
8fdea07fbd
commit
ebea84d077
@ -1,3 +0,0 @@
|
|||||||
export function isHeadscaleServeCmd(cmdline: string): boolean {
|
|
||||||
return cmdline.includes('headscale') && cmdline.includes("serve");
|
|
||||||
}
|
|
||||||
@ -7,7 +7,6 @@ import { ApiClient } from '~/server/headscale/api-client';
|
|||||||
import log from '~/utils/log';
|
import log from '~/utils/log';
|
||||||
import { HeadplaneConfig } from '../schema';
|
import { HeadplaneConfig } from '../schema';
|
||||||
import { Integration } from './abstract';
|
import { Integration } from './abstract';
|
||||||
import { isHeadscaleServeCmd } from './cmdline.ts';
|
|
||||||
|
|
||||||
type T = NonNullable<HeadplaneConfig['integration']>['proc'];
|
type T = NonNullable<HeadplaneConfig['integration']>['proc'];
|
||||||
export default class ProcIntegration extends Integration<T> {
|
export default class ProcIntegration extends Integration<T> {
|
||||||
@ -39,9 +38,11 @@ export default class ProcIntegration extends Integration<T> {
|
|||||||
try {
|
try {
|
||||||
log.debug('config', 'Reading %s', path);
|
log.debug('config', 'Reading %s', path);
|
||||||
const data = await readFile(path, 'utf8');
|
const data = await readFile(path, 'utf8');
|
||||||
if (isHeadscaleServeCmd(data)) {
|
if (!data.includes('headscale') && !data.includes('serve')) {
|
||||||
return pid;
|
throw new Error('Found PID without Headscale serve command');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return pid;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error('config', 'Failed to read %s: %s', path, error);
|
log.error('config', 'Failed to read %s: %s', path, error);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user