Skip to content

Commit

Permalink
Added handler for 'SIGINT' event.
Browse files Browse the repository at this point in the history
  • Loading branch information
scholtzm committed Jul 8, 2015
1 parent c3fa27d commit d942938
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ var vapor = new Vapor();

// Let's go!
vapor.init(config);

// Handle SIGINT
process.on('SIGINT', function() {
vapor.shutdown();
});
12 changes: 12 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ Vapor.prototype.init = function(config) {
this._login(config.username, config.password);
};

/**
* Gracefully shuts down Vapor.
*/
Vapor.prototype.shutdown = function() {
this.log.info("Logging off and shutting down.");
this.client.logOff();

setTimeout(function() {
process.exit(0);
}, 500);
};

/**
* Login method.
* @param username Steam account username.
Expand Down

0 comments on commit d942938

Please sign in to comment.