UNPKG

foxy-proxy

Version:

A Proof of Capacity proxy which supports solo and pool mining upstreams.

36 lines (29 loc) 570 B
#!/usr/bin/env node const { fork } = require('child_process'); class FoxyProxy { constructor() { this.start(); } start() { this.app = fork(`${__dirname}/app.js`, process.argv.slice(2), { cwd: process.cwd(), }); this.app.on('message', this.onMessage.bind(this)); } stop() { if (!this.app) { return; } this.app.kill(); this.app = null; } onMessage(message) { switch(message) { case 'restart': this.stop(); this.start(); break; } } } const foxyProxy = new FoxyProxy();