Skip to content

Commit efb8b55

Browse files
committed
Passing new options object to stop()
1 parent 11f19ac commit efb8b55

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

scripts/stackstorm.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ module.exports = function(robot) {
175175
robot.logger.error('Failed to authenticate: ' + err.message);
176176

177177
if (env.EXIT_ON_FAILURES) {
178-
stop({exitOnFailure: true});
178+
stop({exit: true});
179179
} else {
180180
throw err;
181181
}
@@ -206,10 +206,10 @@ module.exports = function(robot) {
206206
// handler to manage per adapter message post-ing.
207207
var postDataHandler = postData.getDataPostHandler(robot.adapterName, robot, formatter);
208208

209-
var loadCommands = function(exitOpts) {
209+
var loadCommands = function(opts) {
210210
robot.logger.info('Loading commands....');
211211

212-
var exitOpts = _.merge({}, {exitOnFailure: false }, exitOpts)
212+
var opts = _.merge({exitOnFailure: false}, opts);
213213

214214
api.actionAlias.list()
215215
.then(function (aliases) {
@@ -247,8 +247,8 @@ module.exports = function(robot) {
247247
.catch(function (err) {
248248
var error_msg = 'Failed to retrieve commands from "%s": %s';
249249
robot.logger.error(util.format(error_msg, env.ST2_API_URL, err.message));
250-
if (exitOpts.exitOnFailure) {
251-
stop(exitOpts);
250+
if (opts.exitOnFailure) {
251+
stop({exit: true});
252252
}
253253
});
254254
};
@@ -431,15 +431,18 @@ module.exports = function(robot) {
431431
install_sigusr2_handler();
432432
}
433433

434-
function stop(exitOpts) {
434+
function stop(opts) {
435+
var opts = _.merge({exit: false}, opts);
436+
435437
clearInterval(commands_load_interval);
436438
api.stream.listen().then(function (source) {
437439
source.removeAllListeners();
438440
source.close();
439441
});
440442

441-
if (exitOpts.exitOnFailure) {
442-
process.exit(1)
443+
if (opts.exit) {
444+
robot.server.close();
445+
robot.shutdown();
443446
}
444447
}
445448

0 commit comments

Comments
 (0)