提交 22dd2146 编写于 作者: B Benjamin Pasero

watcher: do not blindly try to restart a crashing watcher until the end of days

上级 739164e3
......@@ -25,10 +25,14 @@ export class WatcherService {
}
export class FileWatcher {
private static MAX_RESTARTS = 5;
private isDisposed: boolean;
private restartCounter: number;
constructor(private basePath: string, private ignored: string[], private eventEmitter: IEventService, private errorLogger: (msg: string) => void, private verboseLogging: boolean) {
this.isDisposed = false;
this.restartCounter = 0;
}
public startWatching(): () => void {
......@@ -55,9 +59,15 @@ export class FileWatcher {
}, (events: IRawFileChange[]) => this.onRawFileEvents(events)).done(() => {
// our watcher app should never be completed because it keeps on watching. being in here indicates
// that the watcher process died and we want to restart it here.
// that the watcher process died and we want to restart it here. we only do it a max number of times
if (!this.isDisposed) {
this.startWatching();
if (this.restartCounter <= FileWatcher.MAX_RESTARTS) {
this.errorLogger('Watcher terminated unexpectedly and is restarted again...');
this.restartCounter++;
this.startWatching();
} else {
this.errorLogger('Watcher failed to start after retrying for some time, giving up. Please report this as a bug report!');
}
}
}, this.errorLogger);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册