forked from statsd/statsd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for setting the process wtitle, or opting to let the os do it l…
…ike previous versions
- Loading branch information
Showing
4 changed files
with
85 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var util = require('util'); | ||
|
||
var conf; | ||
|
||
exports.init = function(config) { | ||
conf = config; | ||
exports.set_title(config); | ||
|
||
process.on('SIGTERM', function() { | ||
if (conf.debug) { | ||
util.log('Starting Final Flush'); | ||
} | ||
healthStatus = 'down'; | ||
process.exit(); | ||
}); | ||
|
||
} | ||
|
||
exports.set_title = function(config) { | ||
if (config.title !== undefined) { | ||
if (config.title) { | ||
if (process.title.length >= config.title.length) { | ||
process.title = config.title; | ||
} else { | ||
// check that conf is defined so we don't error in tests | ||
if (conf !== undefined && conf.debug) { | ||
util.log("config.title is to long, needs to be less than or equal to" + process.title.length); | ||
} | ||
} | ||
} | ||
} else { | ||
process.title = 'statsd'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
var process_mgmt = require('../lib/process_mgmt'); | ||
|
||
var config = {} | ||
module.exports = { | ||
|
||
setUp: function(callback) { | ||
config = {}; | ||
callback(); | ||
}, | ||
|
||
test_valid_title: function(test){ | ||
test.expect(1); | ||
process_title = process.title; | ||
config.title = process_title.substring(1); | ||
process_mgmt.set_title(config); | ||
test.ok(process.title == config.title, "Can set a title that is less than or equal to the process title length"); | ||
test.done(); | ||
}, | ||
|
||
test_invalid_title: function(test){ | ||
process_title = process.title; | ||
test_title = process.title + "1"; | ||
config.title = test_title; | ||
process_mgmt.set_title(config); | ||
test.ok(process.title == process_title, "Can't set a title that is longer than the process.title length"); | ||
test.done(); | ||
}, | ||
|
||
test_no_title: function(test){ | ||
process_title = process.title; | ||
config.title = false; | ||
process_mgmt.set_title(config); | ||
test.ok(process_title == process.title, "A config.title of false should not override the default node process.title"); | ||
test.done(); | ||
}, | ||
|
||
test_default_title: function(test){ | ||
default_title = 'statsd'; | ||
process_mgmt.set_title(config); | ||
test.ok(process.title == default_title, "If no config.title option set, set the process.title to statsd"); | ||
test.done(); | ||
} | ||
|
||
}; |