fix: improve headscale proc detection
Check if command line also includes 'serve'. Move command line processing logic into a helper function.
This commit is contained in:
parent
59874ca749
commit
a993908ebc
3
app/server/config/integration/cmdline.ts
Normal file
3
app/server/config/integration/cmdline.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export function isHeadscaleServeCmd(cmdline: string): boolean {
|
||||
return cmdline.includes('headscale') && cmdline.includes("serve");
|
||||
}
|
||||
@ -8,6 +8,7 @@ import { ApiClient } from '~/server/headscale/api-client';
|
||||
import log from '~/utils/log';
|
||||
import { HeadplaneConfig } from '../schema';
|
||||
import { Integration } from './abstract';
|
||||
import { isHeadscaleServeCmd } from './cmdline.ts';
|
||||
|
||||
// TODO: Upgrade to the new CoreV1Api from @kubernetes/client-node
|
||||
type T = NonNullable<HeadplaneConfig['integration']>['kubernetes'];
|
||||
@ -162,7 +163,7 @@ export default class KubernetesIntegration extends Integration<T> {
|
||||
try {
|
||||
log.debug('config', 'Reading %s', path);
|
||||
const data = await readFile(path, 'utf8');
|
||||
if (data.includes('headscale')) {
|
||||
if (isHeadscaleServeCmd(data)) {
|
||||
return pid;
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@ -7,6 +7,7 @@ import { ApiClient } from '~/server/headscale/api-client';
|
||||
import log from '~/utils/log';
|
||||
import { HeadplaneConfig } from '../schema';
|
||||
import { Integration } from './abstract';
|
||||
import { isHeadscaleServeCmd } from './cmdline.ts';
|
||||
|
||||
type T = NonNullable<HeadplaneConfig['integration']>['proc'];
|
||||
export default class ProcIntegration extends Integration<T> {
|
||||
@ -38,7 +39,7 @@ export default class ProcIntegration extends Integration<T> {
|
||||
try {
|
||||
log.debug('config', 'Reading %s', path);
|
||||
const data = await readFile(path, 'utf8');
|
||||
if (data.includes('headscale')) {
|
||||
if (isHeadscaleServeCmd(data)) {
|
||||
return pid;
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user