use supervisor instead of pm2 for stability
This commit is contained in:
parent
5ab77c560f
commit
2f94e07788
10 changed files with 46 additions and 35 deletions
|
|
@ -2,9 +2,10 @@ const crypto = require('crypto')
|
|||
const os = require('os')
|
||||
const path = require('path')
|
||||
const cp = require('child_process')
|
||||
const fs = require('fs')
|
||||
const logger = require('console-log-level')({level: 'info'})
|
||||
|
||||
module.exports = {es, firewall, randomPass, fetchAndInstall, logger}
|
||||
module.exports = {es, writeSupervisorConfig, firewall, randomPass, fetchAndInstall, logger}
|
||||
|
||||
const BINARIES = {
|
||||
BTC: {
|
||||
|
|
@ -47,6 +48,21 @@ function es (cmd) {
|
|||
return res.toString()
|
||||
}
|
||||
|
||||
function writeSupervisorConfig (coinRec, cmd) {
|
||||
const blockchain = coinRec.code
|
||||
|
||||
const supervisorConfig = `[program:${blockchain}]
|
||||
command=${cmd}
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stderr_logfile=/var/log/supervisor/${blockchain}.err.log
|
||||
stdout_logfile=/var/log/supervisor/${blockchain}.out.log
|
||||
environment=HOME="/root"
|
||||
`
|
||||
|
||||
fs.writeFileSync(`/etc/supervisor/conf.d/${coinRec.code}.conf`, supervisorConfig)
|
||||
}
|
||||
|
||||
function fetchAndInstall (crypto) {
|
||||
const binaries = BINARIES[crypto.cryptoCode]
|
||||
if (!binaries) throw new Error(`No such coin: ${crypto.code}`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue