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,19 +2,21 @@ const fs = require('fs')
|
|||
const path = require('path')
|
||||
|
||||
const coinUtils = require('../coin-utils')
|
||||
const options = require('../options')
|
||||
|
||||
const common = require('./common')
|
||||
|
||||
module.exports = {setup}
|
||||
|
||||
const es = common.es
|
||||
const coinRec = coinUtils.getCryptoCurrency('BTC')
|
||||
|
||||
function setup (dataDir) {
|
||||
const coinRec = coinUtils.getCryptoCurrency('BTC')
|
||||
common.firewall([coinRec.defaultPort])
|
||||
const config = buildConfig()
|
||||
fs.writeFileSync(path.resolve(dataDir, coinRec.configFile), config)
|
||||
setupPm2(dataDir)
|
||||
const blockchainDir = options.blockchainDir
|
||||
const cmd = `/usr/local/bin/${coinRec.daemon} -datadir=${blockchainDir}`
|
||||
common.writeSupervisorConfig(coinRec, cmd)
|
||||
}
|
||||
|
||||
function buildConfig () {
|
||||
|
|
@ -27,7 +29,3 @@ keypool=10000
|
|||
prune=4000
|
||||
daemon=0`
|
||||
}
|
||||
|
||||
function setupPm2 (dataDir) {
|
||||
es(`pm2 start /usr/local/bin/bitcoind -- -datadir=${dataDir}`)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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}`)
|
||||
|
|
|
|||
|
|
@ -2,19 +2,21 @@ const fs = require('fs')
|
|||
const path = require('path')
|
||||
|
||||
const coinUtils = require('../coin-utils')
|
||||
const options = require('../options')
|
||||
|
||||
const common = require('./common')
|
||||
|
||||
module.exports = {setup}
|
||||
|
||||
const es = common.es
|
||||
const coinRec = coinUtils.getCryptoCurrency('BTC')
|
||||
|
||||
function setup (dataDir) {
|
||||
const coinRec = coinUtils.getCryptoCurrency('DASH')
|
||||
common.firewall([coinRec.defaultPort])
|
||||
const config = buildConfig()
|
||||
const blockchainDir = options.blockchainDir
|
||||
fs.writeFileSync(path.resolve(dataDir, coinRec.configFile), config)
|
||||
setupPm2(dataDir)
|
||||
const cmd = `/usr/local/bin/${coinRec.daemon} -datadir=${blockchainDir}`
|
||||
common.writeSupervisorConfig(coinRec, cmd)
|
||||
}
|
||||
|
||||
function buildConfig () {
|
||||
|
|
@ -22,7 +24,3 @@ function buildConfig () {
|
|||
rpcpassword=${common.randomPass()}
|
||||
dbcache=500`
|
||||
}
|
||||
|
||||
function setupPm2 (dataDir) {
|
||||
es(`pm2 start /usr/local/bin/dashd -- -datadir=${dataDir}`)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,11 @@ function locateVolume () {
|
|||
}
|
||||
|
||||
function prepareVolume () {
|
||||
if (isMounted()) {
|
||||
logger.info('Volume is already mounted.')
|
||||
return true
|
||||
}
|
||||
|
||||
const volumePath = locateVolume()
|
||||
if (!volumePath) return false
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,14 @@
|
|||
const coinUtils = require('../coin-utils')
|
||||
const options = require('../options')
|
||||
|
||||
const common = require('./common')
|
||||
|
||||
module.exports = {setup}
|
||||
|
||||
const es = common.es
|
||||
|
||||
function setup (dataDir) {
|
||||
const coinRec = coinUtils.getCryptoCurrency('ETH')
|
||||
common.firewall([coinRec.defaultPort])
|
||||
setupPm2(dataDir)
|
||||
}
|
||||
|
||||
function setupPm2 (dataDir) {
|
||||
es(`pm2 start /usr/local/bin/geth -- --datadir "${dataDir}" --cache 500`)
|
||||
const blockchainDir = options.blockchainDir
|
||||
const cmd = `/usr/local/bin/${coinRec.daemon} --datadir "${blockchainDir}" --cache 500`
|
||||
common.writeSupervisorConfig(coinRec, cmd)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ function processCryptos (codes) {
|
|||
|
||||
const selectedCryptos = _.map(code => _.find(['code', code], cryptos), codes)
|
||||
_.forEach(setupCrypto, selectedCryptos)
|
||||
common.es('pm2 save')
|
||||
common.es('sudo service supervisor restart')
|
||||
logger.info('Installation complete.')
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,19 +2,21 @@ const fs = require('fs')
|
|||
const path = require('path')
|
||||
|
||||
const coinUtils = require('../coin-utils')
|
||||
const options = require('../options')
|
||||
|
||||
const common = require('./common')
|
||||
|
||||
module.exports = {setup}
|
||||
|
||||
const es = common.es
|
||||
const coinRec = coinUtils.getCryptoCurrency('LTC')
|
||||
|
||||
function setup (dataDir) {
|
||||
const coinRec = coinUtils.getCryptoCurrency('LTC')
|
||||
common.firewall([coinRec.defaultPort])
|
||||
const config = buildConfig()
|
||||
fs.writeFileSync(path.resolve(dataDir, coinRec.configFile), config)
|
||||
setupPm2(dataDir)
|
||||
const blockchainDir = options.blockchainDir
|
||||
const cmd = `/usr/local/bin/${coinRec.daemon} -datadir=${blockchainDir}`
|
||||
common.writeSupervisorConfig(coinRec, cmd)
|
||||
}
|
||||
|
||||
function buildConfig () {
|
||||
|
|
@ -27,7 +29,3 @@ keypool=10000
|
|||
prune=4000
|
||||
daemon=0`
|
||||
}
|
||||
|
||||
function setupPm2 (dataDir) {
|
||||
es(`pm2 start /usr/local/bin/litecoind -- -datadir=${dataDir}`)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ const fs = require('fs')
|
|||
const path = require('path')
|
||||
|
||||
const coinUtils = require('../coin-utils')
|
||||
const options = require('../options')
|
||||
|
||||
const common = require('./common')
|
||||
|
||||
|
|
@ -21,7 +22,9 @@ function setup (dataDir) {
|
|||
logger.info('Finished fetching proofs.')
|
||||
const config = buildConfig()
|
||||
fs.writeFileSync(path.resolve(dataDir, 'zcash.conf'), config)
|
||||
setupPm2(dataDir)
|
||||
const blockchainDir = options.blockchainDir
|
||||
const cmd = `/usr/local/bin/${coinRec.daemon} -datadir=${blockchainDir}`
|
||||
common.writeSupervisorConfig(coinRec, cmd)
|
||||
}
|
||||
|
||||
function buildConfig () {
|
||||
|
|
@ -31,7 +34,3 @@ rpcuser=lamassuserver
|
|||
rpcpassword=${common.randomPass()}
|
||||
dbcache=500`
|
||||
}
|
||||
|
||||
function setupPm2 (dataDir) {
|
||||
es(`pm2 start /usr/local/bin/zcashd -- -datadir=${dataDir}`)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue