Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

grudzinski/sdt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'));
});

About

Simple daemon tools

Resources

Stars

Watchers

Forks

Packages

No packages published