Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async removeFiles (service: Service) {
const repositoryPath = await getRepositoryPath()
const socketFilename = `servicectl.${service.name}@.socket`
const serviceFilename = `servicectl.${service.name}@.service`
const serviceFilepath = path.resolve(repositoryPath, serviceFilename)
const socketFilepath = path.resolve(repositoryPath, socketFilename)
// dont handle error, we just want to remove the file, fine if already the case
let ret = await of(promisify(fs.unlink)(serviceFilepath))
ret = await of(promisify(fs.unlink)(socketFilepath))
}
async removeFiles (service: Service) {
const repositoryPath = await getRepositoryPath()
const serviceFilename = `servicectl.${service.name}.service`
const serviceFilepath = path.resolve(repositoryPath, serviceFilename)
const [ _, err ] = await of(promisify(fs.unlink)(serviceFilepath))
// dont handle error, we just want to remove the file, fine if already the case
}
async disable (service: Service, manager: SystemdManager) {
const serviceFilename = `servicectl.${service.name}.service`
await of(manager.StopUnit(serviceFilename, StartMode.FAIL))
await of(manager.DisableUnitFiles([serviceFilename], false))
await manager.Reload()
}
}
async disable (service: Service, manager: SystemdManager) {
const serviceFilename = `servicectl.${service.name}.service`
await of(manager.StopUnit(serviceFilename, StartMode.FAIL))
await of(manager.DisableUnitFiles([serviceFilename], false))
await manager.Reload()
}
}
export const watchFileUpdate = async (path: string, onUpdate: Function): Promise => {
const [ stat ] = await of(promises.stat(path))
const state: WatchedFile = {
offset: stat.size || 0,
BUFFER_SIZE: 2048
}
const cancel = async () => {
if (state.handle !== undefined) {
await state.handle.close()
}
if (state.watcher !== undefined) {
state.watcher.close()
}
}
const onFileUpdate = async (type: string) => {
if (type !== 'change') return
if (state.handle === undefined) {