try {
mkdirp.sync(path.join(__dirname, '..', dir))
} catch (error) {
- // Do not use logger
- console.error('Cannot create ' + path + ':' + error)
- process.exit(0)
+ throw new Error('Cannot create ' + path + ':' + error)
}
}
}
function connect () {
mongoose.connect('mongodb://' + host + ':' + port + '/' + dbname)
mongoose.connection.on('error', function () {
- logger.error('Mongodb connection error.')
- process.exit(0)
+ throw new Error('Mongodb connection error.')
})
mongoose.connection.on('open', function () {
// Run a timeout of 30s after which we exit the process
var timeout_webtorrent_process = setTimeout(function () {
- logger.error('Timeout : cannot run the webtorrent process. Please ensure you have electron-prebuilt npm package installed with xvfb-run.')
- process.exit()
+ throw new Error('Timeout : cannot run the webtorrent process. Please ensure you have electron-prebuilt npm package installed with xvfb-run.')
}, 30000)
ipc.server.on(processKey + '.ready', function () {
})
ipc.server.on(processKey + '.exception', function (data) {
- logger.error('Received exception error from webtorrent process.', { exception: data.exception })
- process.exit()
+ throw new Error('Received exception error from webtorrent process.' + data.exception)
})
var webtorrent_process = spawn(pathUtils.join(__dirname, 'webtorrentProcess.js'), host, port, { detached: true })
var ipc = require('node-ipc')
if (args.length !== 3) {
- console.log('Wrong arguments number: ' + args.length + '/3')
- process.exit(-1)
+ throw new Error('Wrong arguments number: ' + args.length + '/3')
}
var host = args[1]
var miss = checker.checkConfig()
if (miss.length !== 0) {
- // Do not use logger module
- console.error('Miss some configurations keys.', { miss: miss })
- process.exit(0)
+ throw new Error('Miss some configurations keys : ' + miss)
}
checker.createDirectoriesIfNotExist()
}
function exitGracefullyOnSignal () {
- process.exit()
+ process.exit(-1)
}
process.on('exit', cleanForExit)