fix(TALE-7): don't destructure context otherwise it won't set properly

This commit is contained in:
Aarnav Tale 2024-08-02 16:14:05 -04:00
parent 6b278309ed
commit b170e11dd6
No known key found for this signature in database
3 changed files with 46 additions and 38 deletions

View file

@ -16,7 +16,7 @@ export default createIntegration<Context>({
context: {
pid: undefined,
},
isAvailable: async ({ pid }) => {
isAvailable: async (context) => {
if (platform() !== 'linux') {
log.error('INTG', '/proc is only available on Linux')
return false
@ -63,8 +63,8 @@ export default createIntegration<Context>({
return false
}
pid = pids[0]
log.info('INTG', 'Found Headscale process with PID: %d', pid)
context.pid = pids[0]
log.info('INTG', 'Found Headscale process with PID: %d', context.pid)
return true
} catch {
log.error('INTG', 'Failed to read /proc')
@ -72,12 +72,12 @@ export default createIntegration<Context>({
}
},
onAclChange: ({ pid }) => {
if (!pid) {
onAclChange: (context) => {
if (!context.pid) {
return
}
log.info('INTG', 'Sending SIGHUP to Headscale')
kill(pid, 'SIGHUP')
kill(context.pid, 'SIGHUP')
},
})