Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[minor] Small updates to 0.2.0

  • Loading branch information...
commit 78e53a21f022e5948e8c393a74f8e37aa4d7251b 1 parent 9dc933e
Charlie Robbins indexzero authored

Showing 2 changed files with 12 additions and 4 deletions. Show diff stats Hide diff stats

  1. +3 3 README.md
  2. +9 1 lib/daemon.js
6 README.md
Source Rendered
@@ -31,7 +31,7 @@ Starting a daemon is easy, just call daemon.start() and daemon.lock().
31 31 // Your awesome code here
32 32
33 33 fs.open('somefile.log', 'w+', function (err, fd) {
34   - daemon.daemonize();
  34 + daemon.daemonize(fd);
35 35 daemon.lock('/tmp/yourprogram.pid');
36 36 });
37 37 </pre>
@@ -43,11 +43,11 @@ This library also exposes a higher level facility through javascript for startin
43 43
44 44 // Your awesome code here
45 45
46   - daemon.daemonize('somefile.log', '/tmp/yourprogram.pid', function (err, started) {
  46 + daemon.daemonize('somefile.log', '/tmp/yourprogram.pid', function (err, pid) {
47 47 // We are now in the daemon process
48 48 if (err) return sys.puts('Error starting daemon: ' + err);
49 49
50   - sys.puts('Daemon started successfully');
  50 + sys.puts('Daemon started successfully with pid: ' + pid);
51 51 });
52 52 </pre>
53 53
10 lib/daemon.js
@@ -16,11 +16,19 @@ var fs = require('fs'),
16 16 Object.keys(binding).forEach(function (k) { daemon[k] = binding[k] });
17 17
18 18 //
19   -// function run (out, lock, callback)
  19 +// function daemonize ([out, lock, callback])
20 20 // Run is designed to encapsulate the basic daemon operation in a single async call.
21 21 // When the callback returns you are in the the child process.
22 22 //
23 23 daemon.daemonize = function (out, lock, callback) {
  24 + //
  25 + // If we only get one argument assume it's an fd and
  26 + // simply return with the pid from binding.daemonize(fd);
  27 + //
  28 + if (arguments.length === 1) {
  29 + return binding.daemonize(out);
  30 + }
  31 +
24 32 fs.open(out, 'w+', function (err, fd) {
25 33 if (err) return callback(err);
26 34

0 comments on commit 78e53a2

Please sign in to comment.
Something went wrong with that request. Please try again.