Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (root && opts.watch !== false) {
var urlsByFile = {}
fn.watcher = filewatcher({ delay: opts.delay })
// Stop the file system watcher so apps can exit gracefully when
// terminated by Ctrl+c (SIGINT) or a polite termination request (SIGTERM).
// You can also call the cleanUp() function directly to handle housekeeping
// in your own server (e.g., when it is asked to close).
fn.cleanUp = function (done) {
fn.watcher.removeAll()
done()
}
Graceful.timeout = 3000
Graceful.on('SIGINT', fn.cleanUp)
Graceful.on('SIGTERM', fn.cleanUp)
// when a file is modifed tell all clients to reload it
fn.watcher.on('change', function(file) {
fn.reload(urlsByFile[file])
})
// build a RegExp to match all watched file extensions
var exts = opts.watch || ['html', 'js', 'css']
, re = new RegExp('\\.(' + exts.join('|') + ')$')
// pass an `onfile` handler that watches matching files
opts = Object.create(opts, {
onfile: { value: function(path, stat) {
if (!re.test(path)) return
urlsByFile[path] = this.path
this._maxage = 0
if (root && opts.watch !== false) {
var urlsByFile = {}
fn.watcher = filewatcher({ delay: opts.delay })
// Stop the file system watcher so apps can exit gracefully when
// terminated by Ctrl+c (SIGINT) or a polite termination request (SIGTERM).
// You can also call the cleanUp() function directly to handle housekeeping
// in your own server (e.g., when it is asked to close).
fn.cleanUp = function (done) {
fn.watcher.removeAll()
done()
}
Graceful.timeout = 3000
Graceful.on('SIGINT', fn.cleanUp)
Graceful.on('SIGTERM', fn.cleanUp)
// when a file is modifed tell all clients to reload it
fn.watcher.on('change', function(file) {
fn.reload(urlsByFile[file])
})
// build a RegExp to match all watched file extensions
var exts = opts.watch || ['html', 'js', 'css']
, re = new RegExp('\\.(' + exts.join('|') + ')$')
// pass an `onfile` handler that watches matching files
opts = Object.create(opts, {
onfile: { value: function(path, stat) {
if (!re.test(path)) return
urlsByFile[path] = this.path
}
if (root && opts.watch !== false) {
var urlsByFile = {}
fn.watcher = filewatcher({ delay: opts.delay })
// Stop the file system watcher so apps can exit gracefully when
// terminated by Ctrl+c (SIGINT) or a polite termination request (SIGTERM).
// You can also call the cleanUp() function directly to handle housekeeping
// in your own server (e.g., when it is asked to close).
fn.cleanUp = function (done) {
fn.watcher.removeAll()
done()
}
Graceful.timeout = 3000
Graceful.on('SIGINT', fn.cleanUp)
Graceful.on('SIGTERM', fn.cleanUp)
// when a file is modifed tell all clients to reload it
fn.watcher.on('change', function(file) {
fn.reload(urlsByFile[file])
})
// build a RegExp to match all watched file extensions
var exts = opts.watch || ['html', 'js', 'css']
, re = new RegExp('\\.(' + exts.join('|') + ')$')
// pass an `onfile` handler that watches matching files
opts = Object.create(opts, {
onfile: { value: function(path, stat) {
if (!re.test(path)) return
.then((dir) => {
newDir = dir;
removeOnExit = graceful.on("exit", remove, true);
return newDir;
});
// tslint:disable-next-line:prefer-object-spread
onStop(fn: StopFunc) {
if (!this.removeOnStop) {
this.removeOnStop = graceful.on("exit", () => this.stop(), true);
}
this.stops.push(fn);
}
}
{env: env, detached: true});
logger.info(`firejailed pid=${wineServer.pid}`);
} else {
logger.info(`Starting a new, long-lived wineserver complex ${server}`);
wineServer = child_process.spawn(
wine,
["cmd"],
{env: env, detached: true});
logger.info(`wineserver pid=${wineServer.pid}`);
}
wineServer.on('close', code => {
logger.info(`WINE server complex exited with code ${code}`);
});
Graceful.on('exit', () => {
const waitingPromises = [];
function waitForExit(process, name) {
return new Promise((resolve) => {
process.on('close', () => {
logger.info(`Process '${name}' closed`);
resolve();
});
});
}
if (wineServer && !wineServer.killed) {
logger.info('Shutting down WINE server complex');
wineServer.kill();
if (wineServer.killed) {
waitingPromises.push(waitForExit(wineServer, "WINE server"));