diff options
-rw-r--r-- | initializers/checker.js | 4 | ||||
-rw-r--r-- | initializers/database.js | 3 | ||||
-rw-r--r-- | lib/webtorrent.js | 6 | ||||
-rw-r--r-- | lib/webtorrentProcess.js | 3 | ||||
-rw-r--r-- | server.js | 6 |
5 files changed, 7 insertions, 15 deletions
diff --git a/initializers/checker.js b/initializers/checker.js index 9a7d04ed4..ec7bc0ad2 100644 --- a/initializers/checker.js +++ b/initializers/checker.js | |||
@@ -36,9 +36,7 @@ function createDirectoriesIfNotExist () { | |||
36 | try { | 36 | try { |
37 | mkdirp.sync(path.join(__dirname, '..', dir)) | 37 | mkdirp.sync(path.join(__dirname, '..', dir)) |
38 | } catch (error) { | 38 | } catch (error) { |
39 | // Do not use logger | 39 | throw new Error('Cannot create ' + path + ':' + error) |
40 | console.error('Cannot create ' + path + ':' + error) | ||
41 | process.exit(0) | ||
42 | } | 40 | } |
43 | } | 41 | } |
44 | } | 42 | } |
diff --git a/initializers/database.js b/initializers/database.js index 6e3f11df3..a917442ec 100644 --- a/initializers/database.js +++ b/initializers/database.js | |||
@@ -16,8 +16,7 @@ var database = { | |||
16 | function connect () { | 16 | function connect () { |
17 | mongoose.connect('mongodb://' + host + ':' + port + '/' + dbname) | 17 | mongoose.connect('mongodb://' + host + ':' + port + '/' + dbname) |
18 | mongoose.connection.on('error', function () { | 18 | mongoose.connection.on('error', function () { |
19 | logger.error('Mongodb connection error.') | 19 | throw new Error('Mongodb connection error.') |
20 | process.exit(0) | ||
21 | }) | 20 | }) |
22 | 21 | ||
23 | mongoose.connection.on('open', function () { | 22 | mongoose.connection.on('open', function () { |
diff --git a/lib/webtorrent.js b/lib/webtorrent.js index 5f10322a5..cb641fead 100644 --- a/lib/webtorrent.js +++ b/lib/webtorrent.js | |||
@@ -43,8 +43,7 @@ function create (options, callback) { | |||
43 | 43 | ||
44 | // Run a timeout of 30s after which we exit the process | 44 | // Run a timeout of 30s after which we exit the process |
45 | var timeout_webtorrent_process = setTimeout(function () { | 45 | var timeout_webtorrent_process = setTimeout(function () { |
46 | logger.error('Timeout : cannot run the webtorrent process. Please ensure you have electron-prebuilt npm package installed with xvfb-run.') | 46 | throw new Error('Timeout : cannot run the webtorrent process. Please ensure you have electron-prebuilt npm package installed with xvfb-run.') |
47 | process.exit() | ||
48 | }, 30000) | 47 | }, 30000) |
49 | 48 | ||
50 | ipc.server.on(processKey + '.ready', function () { | 49 | ipc.server.on(processKey + '.ready', function () { |
@@ -54,8 +53,7 @@ function create (options, callback) { | |||
54 | }) | 53 | }) |
55 | 54 | ||
56 | ipc.server.on(processKey + '.exception', function (data) { | 55 | ipc.server.on(processKey + '.exception', function (data) { |
57 | logger.error('Received exception error from webtorrent process.', { exception: data.exception }) | 56 | throw new Error('Received exception error from webtorrent process.' + data.exception) |
58 | process.exit() | ||
59 | }) | 57 | }) |
60 | 58 | ||
61 | var webtorrent_process = spawn(pathUtils.join(__dirname, 'webtorrentProcess.js'), host, port, { detached: true }) | 59 | var webtorrent_process = spawn(pathUtils.join(__dirname, 'webtorrentProcess.js'), host, port, { detached: true }) |
diff --git a/lib/webtorrentProcess.js b/lib/webtorrentProcess.js index 96ebf9d02..7ba2dd3d9 100644 --- a/lib/webtorrentProcess.js +++ b/lib/webtorrentProcess.js | |||
@@ -5,8 +5,7 @@ function webtorrent (args) { | |||
5 | var ipc = require('node-ipc') | 5 | var ipc = require('node-ipc') |
6 | 6 | ||
7 | if (args.length !== 3) { | 7 | if (args.length !== 3) { |
8 | console.log('Wrong arguments number: ' + args.length + '/3') | 8 | throw new Error('Wrong arguments number: ' + args.length + '/3') |
9 | process.exit(-1) | ||
10 | } | 9 | } |
11 | 10 | ||
12 | var host = args[1] | 11 | var host = args[1] |
@@ -18,9 +18,7 @@ var checker = require('./initializers/checker') | |||
18 | 18 | ||
19 | var miss = checker.checkConfig() | 19 | var miss = checker.checkConfig() |
20 | if (miss.length !== 0) { | 20 | if (miss.length !== 0) { |
21 | // Do not use logger module | 21 | throw new Error('Miss some configurations keys : ' + miss) |
22 | console.error('Miss some configurations keys.', { miss: miss }) | ||
23 | process.exit(0) | ||
24 | } | 22 | } |
25 | 23 | ||
26 | checker.createDirectoriesIfNotExist() | 24 | checker.createDirectoriesIfNotExist() |
@@ -145,7 +143,7 @@ peertubeCrypto.createCertsIfNotExist(function (err) { | |||
145 | } | 143 | } |
146 | 144 | ||
147 | function exitGracefullyOnSignal () { | 145 | function exitGracefullyOnSignal () { |
148 | process.exit() | 146 | process.exit(-1) |
149 | } | 147 | } |
150 | 148 | ||
151 | process.on('exit', cleanForExit) | 149 | process.on('exit', cleanForExit) |