npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

weaver

v0.3.1

Published

Interactive process management system

Downloads

148

Readme

Weaver

Interactive process management system for node.js

Installation

# Global
npm -g install weaver

# Local
npm install weaver

If you have chosen local installation, check your PATH environment variable. npm creates symlinks to all binaries in node_modules/.bin hidden folder. So you may want to prepend it to PATH.

Usage

weaver [--port <number>] [--config <path>] [--debug]
weaver [--port <number>] [--config <path>] upgrade
weaver [--port <number>] restart [[task|pid], ...]
weaver [--port <number>] stop [[task|pid], ...]
weaver [--port <number>] kill <signal> [[task|pid], ...]
weaver [--port <number>] drop <task>
weaver [--port <number>] [--nocolor] status
weaver [--port <number>] [--nocolor] dump
weaver [--port <number>] monitor
weaver [--port <number>] exit

Commands

  • upgrade Extend configuration with tasks from configuration file
  • restart Restart all tasks, task group, task by pid
  • stop Stop all tasks, task group, task by pid
  • kill Send signal to task group or task by pid
  • drop Stop task group and remove it from configuration
  • status Show status for all tasks
  • dump Show current configuration
  • monitor Stream log messages from daemon
  • exit Stop all tasks and exit

Options

--config   Configuration file                                                  [default: weaver.json]
--debug    Do not fork and give additional output
--nocolor  Do not use colors for output
--help     Show help and exit
--version  Show version and exit
--port     Use specified port                                                  [default: 8092]

Also WEAVER_PORT and WEAVER_DEBUG environment variables can be used to set options, but command line options have higher priority.

Configuration example

{
	"path": "..",
	"tasks": {
		"web": {
			"count": 2,
			"source": "lib/main.js",
			"persistent": false,
			"arguments": ["--web", "--port", [8001, 8002]],
			"watch": ["lib/**/*.js", "config/default.js", "config/local.json"],
			"env": {
				"NODE_ENV": "local"
			}
		},

		"worker": {
			"count": 1,
			"timeout": 2000,
			"source": "lib/main.js",
			"persistent": false,
			"arguments": ["--worker"],
			"watch": ["lib/worker/*.js"],
			"env": {
				"NODE_ENV": "local"
			}
		},

		"redis": {
			"count": 1,
			"source": "redis-cli",
			"executable": true,
			"arguments": ["monitor"]
		}
	}
}

With such config file weaver will run three processes and restart them when one of watched files is modified. Fourth process will send commands from redis in monitor mode to log. Processes are organized in three groups and can be managed by group name. For example to restart web processes you need to say

weaver restart web

and to stop redis monitor

weaver stop redis

Processes in the web group get different command line arguments but similar environment. By default tasks have access to PATH, NODE_PATH and HOME environment variables. NODE_PATH is set automatically only when executable flag is not set.

Bash commands to start processes manually in same way as weaver does in example above

NODE_ENV="local" node ../lib/main.js --web --port 8001
NODE_ENV="local" node ../lib/main.js --web --port 8002
NODE_ENV="local" node ../lib/main.js --worker
redis-cli monitor

Configuration file structure

  • path Path to working directory, relative to configuration file or absolute. Optional
  • tasks Task groups
  • count Task count for group. Can be zero
  • source Source file or executable for task group. Relative to cwd or absolute
  • persistent Restart task on unclean exit. Defaults to false. Boolean. Optional
  • executable Source is executable itself and v8 instance is not needed to run it. Defaults to false. Boolean. Optional
  • arguments Arguments for tasks in task group. Nested array should have length equal to task count. Optional
  • env Environment variables for task group. Optional
  • watch Restart all tasks in task group when one of watched files was modified. Optional
  • timeout Timeout between SIGINT and SIGTERM for stop and restart commands. Defaults to 1000ms. Optional
  • runtime Minimal runtime required for persistent task to be restarted after unclean exit. Defaults to 1000ms. Optional
  • cwd Task group working directory. Relative to path or absolute. Optional

Configuration file is validated with JSON Schema from file lib/schema.json.

Logs

Weaver will collect logs for you and send anything from subtasks stdout and stderr to udp4:localhost:8092 (or any other port of your choice). In debug mode this functionality is disabled and logs are printed to stdout. To do something with this logs you can use monitor mode

weaver monitor

Or any other program capable to capture udp

socat udp4-listen:8092 stdout

Copyright and License

Copyright 2012-2016 Alexander Nazarov. All rights reserved.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.