node package manager


use perl's Daemon::Control and your package.json to make a LSB-compatible init script


populate a Daemon::Control-based LSB init script with your package.json!

This package generates sysv init scripts, which is historically what linux distros use to manage daemons. Just follow the directions to hook it into your /etc/init.d directory and you should be good to go!

(Note that these days sysv replacements such as upstart and systemd have their own analogs to these, but upstart-based systems at least are backwards compatible, and systemd probably is as well. If not, writing configs for them are simpler than using perl and Daemon::Control anyway.)

Basically this just populates a template perl script with data from your package.json. PRETTY STRAIGHTFORWARD


$ npm install npm2sysv # use it in your npm scripts
$ sudo npm install npm2sysv -g # install globally
$ sudo cpanm Daemon::Control # see


josh@onix:~/dev/img2txtbot$ npm2sysv
To run your new init script:
    $ ./ start
To install globally:
    $ sudo ./ get_init_file > /etc/init.d/img2txtbot
For more information, see:
josh@onix:~/dev/img2txtbot$ cat
use warnings;
use strict;
use Daemon::Control;
    name        => 'img2txtbot',
    lsb_start   => '$syslog $remote_fs',
    lsb_stop    => '$syslog',
    lsb_sdesc   => 'img2txtbot',
    lsb_desc    => 'A node.js irc bot that uses libcaca and python to turn image links into colorful text representations. Neat!',
    path        => '/home/josh/dev/img2txtbot/',
    program     => sub {
      exec 'cd /home/josh/dev/img2txtbot && npm start';
    pid_file    => '/tmp/',
    stderr_file => '/tmp/img2txtbot.log',
    stdout_file => '/tmp/img2txtbot.log',
    fork        => 2

y u sysv init

  • lowest common denominator
  • pretty sure my ubuntu server already knows what to do with these

y u perl

  • someone I knew already wrote it
  • you try writing a node script that can reliably double-fork. no, go ahead.