fix restart on close/error (TODO: double cehck enable/disable)
This commit is contained in:
parent
961090635c
commit
5d099b36a8
|
@ -535,6 +535,7 @@ function serveControlsHelper() {
|
||||||
|
|
||||||
function enable() {
|
function enable() {
|
||||||
delete state.config.disable;// = undefined;
|
delete state.config.disable;// = undefined;
|
||||||
|
state.keepAlive.state = true;
|
||||||
|
|
||||||
fs.writeFile(confpath, YAML.safeDump(snakeCopy(state.config)), function (err) {
|
fs.writeFile(confpath, YAML.safeDump(snakeCopy(state.config)), function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -805,8 +806,11 @@ function safeStartTelebitRemote(forceOn) {
|
||||||
// this won't restart either
|
// this won't restart either
|
||||||
trPromise = rawStartTelebitRemote(state.keepAlive);
|
trPromise = rawStartTelebitRemote(state.keepAlive);
|
||||||
trPromise.then(function () {
|
trPromise.then(function () {
|
||||||
|
console.log("I'm RIGHT HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||||
|
state.keepAlive.state = true;
|
||||||
trPromise = null;
|
trPromise = null;
|
||||||
}).catch(function () {
|
}).catch(function () {
|
||||||
|
console.log("I FAILED US ALL!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||||
// this will restart
|
// this will restart
|
||||||
state.keepAlive = { state: true };
|
state.keepAlive = { state: true };
|
||||||
trPromise = rawStartTelebitRemote(state.keepAlive);
|
trPromise = rawStartTelebitRemote(state.keepAlive);
|
||||||
|
@ -898,6 +902,7 @@ function rawStartTelebitRemote(keepAlive) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function resolve(val) {
|
function resolve(val) {
|
||||||
|
console.log('[DEBUG] pre-resolve');
|
||||||
if (myResolve) {
|
if (myResolve) {
|
||||||
myResolve(val);
|
myResolve(val);
|
||||||
myResolve = null;
|
myResolve = null;
|
||||||
|
@ -908,7 +913,7 @@ function rawStartTelebitRemote(keepAlive) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onConnect() {
|
function onConnect() {
|
||||||
console.log('DEBUG on connect');
|
console.log('DEBUG [connect]');
|
||||||
myRemote.removeListener('error', onConnectError);
|
myRemote.removeListener('error', onConnectError);
|
||||||
myRemote.once('error', function () {
|
myRemote.once('error', function () {
|
||||||
if (!keepAlive.state) {
|
if (!keepAlive.state) {
|
||||||
|
@ -941,7 +946,7 @@ function rawStartTelebitRemote(keepAlive) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function retryLoop() {
|
function retryLoop() {
|
||||||
console.log('DEBUG retryLoop (will safeReload)');
|
console.log('DEBUG [retryLoop] keepAlive.state', keepAlive.state);
|
||||||
if (keepAlive.state) {
|
if (keepAlive.state) {
|
||||||
safeReload(10 * 1000).then(resolve).catch(reject);
|
safeReload(10 * 1000).then(resolve).catch(reject);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue