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 log = require('signale');
|
||||||
const { config } = require('./../package.json');
|
const { config } = require('./../package.json');
|
||||||
|
|
||||||
title('relay');
|
// title('relay');
|
||||||
|
|
||||||
// let connection = null;
|
// let connection = null;
|
||||||
|
|
||||||
|
|
@ -22,9 +22,7 @@ title('relay');
|
||||||
// })();
|
// })();
|
||||||
|
|
||||||
|
|
||||||
|
log.debug('I AM RELAY!');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
log.debug('this is a test output...')
|
log.debug('this is a test output...');
|
||||||
setTimeout(() => {
|
|
||||||
log.debug('so we never process exit?')
|
|
||||||
}, 1000)
|
|
||||||
}, 1000)
|
}, 1000)
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
(() => {
|
(() => {
|
||||||
const log = require('signale');
|
const log = require('signale');
|
||||||
const { execSync } = require('child_process');
|
const { execSync, spawn } = require('child_process');
|
||||||
const branch = 'master';
|
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 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();
|
const localHash = execSync(`git rev-parse ${branch}`).toString().trim();
|
||||||
if(remoteHash !== localHash) {
|
if(remoteHash !== localHash) {
|
||||||
|
|
@ -13,20 +14,30 @@ function update() {
|
||||||
|
|
||||||
execSync(`git fetch`);
|
execSync(`git fetch`);
|
||||||
execSync(`git pull`);
|
execSync(`git pull`);
|
||||||
|
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...');
|
log.info('restarting relay...');
|
||||||
process.exit(2);
|
setTimeout(() => {
|
||||||
}
|
keepAlive();
|
||||||
}
|
}, 1000);
|
||||||
|
})
|
||||||
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
require('./index.js');
|
|
||||||
|
|
||||||
setInterval(update, 5000);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Reference in New Issue