0.0.20 • Published 10 years ago

sdt v0.0.20

Weekly downloads
85
License
-
Repository
github
Last release
10 years ago

SDT - The Simple Daemon Tools

How to install?

$ npm install sdt -g

Default config

{
	"cwd": "/",
	"command": "true",
	"args": [],
	"out": "/dev/null",
	"err": "/dev/null",
	"monitorOut": "monitor.log",
	"pidFile": "/dev/null"
}

How to use it in a command line?

$ sdt start --config /etc/myd/conf.json # starts daemon and prints daemon's pid
$ sdt start-monitored --config /etc/myd/conf.json # starts daemon 
$ sdt status --config /etc/myd/conf.json # prints daemon status
$ sdt stop --config /etc/myd/conf.json # stops daemon

How to use it in a code?

var sdt = require('sdt');

var conf = {
    cwd: '/',
	command: 'node',
	args: ['/usr/local/lib/node_modules/myd'],
	out: '/var/log/myd.out.log',
	err: '/var/log/myd.err.log',
	pidFile: '/var/run/myd.pid'
};

sdt.start(conf, function(err, pid) {
    if (err) {
        console.log('Fail to start daemon: %s', err);
		return;
	}
	console.log('Daemon started with pid: %s', pid);
});

sdt.getStatus(conf, function(err, status) {
    if (err) {
        console.log('Fail to get status: %s', err);
		return;
	}
	console.log('Daemon %s', (status ? 'is running' : 'was stopped'));
});

sdt.stop(conf, function(err, alreadyStopped) {
    if (err) {
        console.log('Fail to stop: %s', err)
		return;
	}
	console.log('Daemon was ' + (alreadyStopped ? 'already stopped' : 'stopped'));
});
0.0.20

10 years ago

0.0.19

11 years ago

0.0.18

11 years ago

0.0.17

11 years ago

0.0.16

11 years ago

0.0.15

11 years ago

0.0.14

11 years ago

0.0.13

11 years ago

0.0.12

11 years ago

0.0.11

11 years ago

0.0.10

11 years ago

0.0.9

11 years ago

0.0.8

11 years ago

0.0.7

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago

0.0.0

11 years ago