Permalink
Browse files

Fixed `cli()` plugin. Closes #145 [reported by alefnula]

  • Loading branch information...
1 parent c5c883d commit a1587ca7ef6f1d3e1f76441ac22755cc467ea037 @tj tj committed Aug 18, 2011
Showing with 18 additions and 17 deletions.
  1. +18 −17 lib/plugins/pidfiles.js
View
@@ -40,26 +40,27 @@ var fs = require('fs')
module.exports = function(dir){
return function(master){
dir = master.pidfiles = master.resolve(dir || 'pids');
- mkdir(dir, 0755, function(err){
- if (err) throw err;
- // augment master
- master.pidof = function(name){
- var dir = master.pidfiles
- , path = dir + '/' + name + '.pid'
- , pid = fs.readFileSync(path, 'ascii');
+ // augment master
+ master.pidof = function(name){
+ var dir = master.pidfiles
+ , path = dir + '/' + name + '.pid'
+ , pid = fs.readFileSync(path, 'ascii');
- return parseInt(pid, 10);
- };
+ return parseInt(pid, 10);
+ };
- master.workerpids = function(){
- var dir = master.pidfiles;
- return fs.readdirSync(dir).filter(function(file){
- return file.match(/^worker\./);
- }).map(function(file){
- return parseInt(fs.readFileSync(dir + '/' + file, 'ascii'), 10);
- });
- };
+ master.workerpids = function(){
+ var dir = master.pidfiles;
+ return fs.readdirSync(dir).filter(function(file){
+ return file.match(/^worker\./);
+ }).map(function(file){
+ return parseInt(fs.readFileSync(dir + '/' + file, 'ascii'), 10);
+ });
+ };
+
+ mkdir(dir, 0755, function(err){
+ if (err) throw err;
// save worker pids
master.on('worker', function(worker){

0 comments on commit a1587ca

Please sign in to comment.