okay this should work now, if the relay exits
parent
edab16a79f
commit
5aba0d6846
|
|
@ -3,7 +3,7 @@ const net = require('net');
|
|||
const log = require('signale');
|
||||
const { config } = require('./../package.json');
|
||||
|
||||
title('relay');
|
||||
// title('relay');
|
||||
|
||||
// let connection = null;
|
||||
|
||||
|
|
@ -22,9 +22,7 @@ title('relay');
|
|||
// })();
|
||||
|
||||
|
||||
log.debug('I AM RELAY!');
|
||||
setTimeout(() => {
|
||||
log.debug('this is a test output...')
|
||||
setTimeout(() => {
|
||||
log.debug('so we never process exit?')
|
||||
}, 1000)
|
||||
log.debug('this is a test output...');
|
||||
}, 1000)
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
(() => {
|
||||
const log = require('signale');
|
||||
const { execSync } = require('child_process');
|
||||
const { execSync, spawn } = require('child_process');
|
||||
const branch = 'master';
|
||||
let proc;
|
||||
|
||||
function update() {
|
||||
setInterval(function update() {
|
||||
const remoteHash = execSync('git ls-remote https://github.com/marcus13345/valnet.git').toString().split(/[\t\n]/g)[0].trim();
|
||||
const localHash = execSync(`git rev-parse ${branch}`).toString().trim();
|
||||
if(remoteHash !== localHash) {
|
||||
|
|
@ -13,18 +14,28 @@ function update() {
|
|||
|
||||
execSync(`git fetch`);
|
||||
execSync(`git pull`);
|
||||
log.info('restarting relay...');
|
||||
process.exit(2);
|
||||
log.info('killing relay...');
|
||||
try {
|
||||
proc.kill();
|
||||
} catch (e) {
|
||||
log.error('failed to kill active relay...');
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
(function keepAlive() {
|
||||
proc = spawn('node', ['relay'], { stdio: "inherit" });
|
||||
|
||||
proc.on('exit', () => {
|
||||
log.info('restarting relay...');
|
||||
setTimeout(() => {
|
||||
keepAlive();
|
||||
}, 1000);
|
||||
})
|
||||
})();
|
||||
|
||||
|
||||
require('./index.js');
|
||||
|
||||
setInterval(update, 5000);
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Reference in New Issue