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

superwatcher

v0.2.0

Published

Watch a GiT repository for changes

Downloads

1

Readme

Why Care

Sure, you can watch for local file changes and react to those with a script, but can you watch for remote file changes in a git repository?

What It Does

superwatcher:

  • watches git repositories for you
  • keeps those repositores up to date
  • triggers an update hook script on each update

With this simple tool combined with forever you can create an auto updating, auto restarting server. All you need to do to autodeploy to as many nodes as you like is git push.

Unlike pretty much every other autodeploy tool, superwatcher doesn't assume any specific workflow, you can watch any repository and branch you like, triggering an optional script after each update. Since that is just a shell script, you can do what you like

What It Is

superwatcher is a command line program that leverages good old cron to create a series of repository watchdogs.

Seems like folks are generally in love with git hooks, which works great except when one of your nodes is down and misses the hook and jams up the works. Using hooks is a push method. Using cron is a pull method. The benefit is that nodes that are down will eventually catch up as they pull in new changes. Self healing.

Cron is also nice in that is:

  • survives reboots
  • is already there and doesn't require installing another daemon as root

The watchdogs will leave configuration in ~/.superwatcher, just as plain text so you can hack and poke as you see fit.

How To Use It

npm install -g superwatcher

Yep, you'll need node.

superwatcher --help

...get the lay of the land

Update Triggers

These are just shell scripts, in the root of each watched repository.

Hooks wrap the auto update sequence, which goes like this:

  1. Ask the git remote if there are missing local changes
  2. If no, go back to sleep
  3. If yes, run the superwatcher_before_update currently on disk, this will be the prior version, not the one incoming from the remote
  4. Use git to fetch and reset to the current remote revision
  5. Run the superwatcher_after_update currently on disk, this may have been freshly pulled

Environment

Cron is nice, except when it isn't. The exact environment you get in a cron job isn't always what you would expect, so superwatcher lets you set it explicitly. This will be sourced before every autoupdate sequence, and lets you do fun stuff like pick the right node, set PATH, etc.

Enough Already!

Ok, here is how you use the thing:

npm install -g superwatcher

superwatcher init

superwatcher watch git://github.com/wballard/superwatcher.demo.git ~/demo
superwatcher environment ~/demo/environment
superwatcher start

At this point, everything should run. All you need to do in order to push changes is update the git repository, which is ... well, you'll need to switch to your own repository :).

You can see what is going on with:

superwatcher info

And shut the whole thing down with:

superwatcher stop

Make a Sandwich

To get a super simple, self updating server, combine superwatcher with forever --watch --watchDirectory. This will give you auto update, and self restart on update.