Skip to content

Commit

Permalink
Fixed daemon api
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed Apr 27, 2011
1 parent bf4985b commit 45450a7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/node.io/interfaces/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ var usage = ''
+ ' -i, --input <FILE> Read input from FILE\n'
+ ' -o, --output <FILE> Write output to FILE\n'
+ ' -t, --timeout <TIME> Set a timeout for the operation (in seconds)\n'
+ ' -f, --fork [NUM] Fork NUM workers. If NUM isn\'t specified, a\n'
+ ' process is spawned for each CPU core\n'
// + ' -f, --fork [NUM] Fork NUM workers. If NUM isn\'t specified, a\n'
// + ' process is spawned for each CPU core\n'
+ ' -u, --unpack <PASS> Unpack a job using the specified password\n'
+ ' -d, --daemon Daemonize the process (requires daemon.node)\n'
+ ' --spoof Spoof request headers\n'
Expand Down
22 changes: 9 additions & 13 deletions lib/node.io/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ exports.daemonize = function (arg, callback) {
}

var start = function () {
daemon.run(log_file, lock_file, function (err) {
daemon.daemonize(log_file, lock_file, function (err) {
if (err) return status('Error starting daemon: ' + err, 'error');
callback();
});
Expand All @@ -288,7 +288,7 @@ exports.daemonize = function (arg, callback) {
} catch (e) {
return status('Daemon is not running', 'error');
};
daemon.stop(lock_file, function (err, pid) {
daemon.kill(lock_file, function (err, pid) {
if (err && err.errno === 3) {
return status('Daemon is not running', 'error');
} else if (err) {
Expand All @@ -299,24 +299,21 @@ exports.daemonize = function (arg, callback) {
};

switch(arg) {
case 'stop':
stop();
break;

case 'restart':
daemon.stop(lock_file, function () {
case 'stop':
stop();
break;
case 'restart':
daemon.kill(lock_file, function () {
start();
});
break;

break;
case 'log':
try {
console.log(fs.readFileSync(log_file, 'utf8'));
} catch (e) {
return status('No daemon log file', 'error');
};
break;

case 'pid':
try {
var pid = fs.readFileSync(lock_file, 'utf8');
Expand All @@ -326,8 +323,7 @@ exports.daemonize = function (arg, callback) {
return status('Daemon is not running', 'error');
};
break;

default:
default:
start();
break;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "name" : "node.io",
"description" : "A distributed data scraping and processing framework",
"version" : "0.2.6",
"version" : "0.2.7",
"homepage" : "http://github.com/chriso/node.io",
"keywords" : ["data","mapreduce","map","reduce","scraping","html","parsing","parse","scrape","process","processing","data"],
"author" : "Chris O'Hara <cohara87@gmail.com>",
Expand Down

0 comments on commit 45450a7

Please sign in to comment.