Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

background-service-runner

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

background-service-runner

A daemon runner utility for node, python, shell and other executable services. Can be configured to run a monitored or detached child process or groups of processes.

  • 0.91.10
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

Background Service Runner


NPM version Build Status Dependency Status

A daemon runner utility for node, python, shell and other executable services. Can be configured to run a monitored or detached child process or groups of processes.

Overview

Background Service Runner provides support for running executables in the background as detached, independent processes or as fully monitored child processes. The typical use case is to create a short script to run a longer running service like an HTTP web service. It can also be used to start and stop groups of services with a single script.

Installation

npm install background-service-runner --save

Use

The following demonstrates a minimal run script that runs a job as a detached script.

var runner = require('background-service-runner').createDaemonRunner(),
    command = __dirname + '/Job.js',
    child = runner.start( command );
    
console.log('pid: ', child.pid);

By default the runner detaches from the child so that it may exit after spawning the child. If you want the runner to exit immediately after spawning the job, then invoke start/stop like this:

var child = runner.start();
console.log( 'child running on pid: ', child.pid );
runner.stop();

Examples

There is a test runner and executable in the examples directory. Invoke the test runner and observe the log file examples/job.log to see its entries.

Tests

Unit tests written in mocha/chai/should and run using grunt. All code tested with jshint.

make test

- or -

make watch

Mocks

The project exposes two mocks for testing.

  • MockSpawn
  • MockChild
  • MockDaemonRunner

See the existing tests for use, but generally you can use these mocks like this...

var MockSpawn = require('background-service-runner').mocks.MockSpawn;

...

var mock = new MockSpawn(),
	opts = {
		log:log,
		spawn:mock.spawn
	},
	runner = new DaemonRunner( opts );
	
var child = runner.start( 'mycommand', [ 'foo', 'bar' ] );

should.exist( child );
child.pid.should.be.above( 1000 );

Note: works in linux/unix but not tested in windows.


Copyright © 2014-2016, rain city software | Version 0.91.10

Keywords

FAQs

Package last updated on 19 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc