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

restarter

Package Overview
Dependencies
Maintainers
0
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

restarter

Start/stop daemon

  • 1.1.17
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
0
Weekly downloads
 
Created
Source

Restarter - start-stop-daemon for multiple processes

Restarter is a simple tool to manage processs similar to forever or unix's start-stop-daemon. You can cause a process to restart simply by touching a file, or prevent a process from dying by setting the keep_alive flag. Each process' console output is appended to a log file of your choosing. There are several tools out there like this, but I couldn't find one that managed a list of processes from a single configuration so I wrote my own. We use this tool to restart standalone processes during our capistrano deployment scripts.

Quick Example:

Make a config called "restarter.conf" file that looks like this:

{
  "global_log_file": "/tmp/restarter_output.log",
  "keep_alive": true,
  "restartables":
    [
      {
        "command": "node /tmp/test.js",
        "pid_file": "/tmp/test.pid",
        "signal": "SIGINT",
        "log_file": "/tmp/test.log",
        "watch_file": "/tmp/test.restarter"
      },
      {
        "command": "node /tmp/test2.js",
        "pid_file": "/tmp/test2.pid",
        "signal": "SIGINT",
        "log_file": "/tmp/test2.log",
        "watch_file": "/tmp/test2.restarter"
      }
    ]
}

Then run it like this:

restarter restarter.conf

If keep_alive is set to "true", it will rerun the command if the process pid is missing. You can "touch" the watch_file and restarter will kill the current process and rerun the command to restart it. If you omit the global_log_file parameter, it will send stdout to the console.

The output in the global_log_file will look something like this:

Thu Jan 27 2011 18:01:00 GMT-0800 (PST) : could not find pid to kill: 4918
Thu Jan 27 2011 18:01:00 GMT-0800 (PST) : spawn pid: 4981 from command: node /tmp/test.js
Thu Jan 27 2011 18:01:00 GMT-0800 (PST) : could not find pid to kill: 4919
Thu Jan 27 2011 18:01:00 GMT-0800 (PST) : spawn pid: 4982 from command: node /tmp/test2.js
Thu Jan 27 2011 18:07:44 GMT-0800 (PST) : keep alive command died, pid: 4982 for command: node /tmp/test2.js
Thu Jan 27 2011 18:07:44 GMT-0800 (PST) : rerunning command: node /tmp/test2.js
Thu Jan 27 2011 18:07:44 GMT-0800 (PST) : could not find pid to kill: 4982
Thu Jan 27 2011 18:07:44 GMT-0800 (PST) : spawn pid: 5967 from command: node /tmp/test2.js
Thu Jan 27 2011 18:08:01 GMT-0800 (PST) : watch file updated for command: node /tmp/test2.js
Thu Jan 27 2011 18:08:01 GMT-0800 (PST) : killed: 5967
Thu Jan 27 2011 18:08:01 GMT-0800 (PST) : spawn pid: 6013 from command: node /tmp/test2.js

FAQs

Package last updated on 28 Mar 2011

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