• Stars
    star
    320
  • Rank 131,126 (Top 3 %)
  • Language
    Go
  • License
    MIT License
  • Created about 11 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A tool that watches files, and runs possibly long-lived commands when they change.

justrun

Justrun watches files and directories and will perform the command given it when those files change. Unlike similar tools, it will terminate the running command and rerun it if more filesystem events occur. This makes it ideal for testing servers. (For instance, a web server whose templates you are editing.)

Justrun also lets you say how long to wait before running the command again, even if filesystem events have occurred in the meantime. See the -delay option in the Usage section.

When a directory is passed in as an argument, justrun will watch all files in that directory, but does not recurse into subdirectories. If you need that recursion, a trick you can pull is using find . -type d and the -stdin option to include all directories recursively. When playing tricks like this, use the ignored file list option (-i) wisely. If not, you'll accidentally watch files that your command touch, and put your commands into an infinite loop.

Justrun does kill the child processes of the bash command run by it to end the lifecycles of long-lived (that is, server) processes. If want justrun to wait for the commands to finish before checking for more filesystem changes, add the -w argument to the commandline.

Examples

justrun -c 'go build && ./mywebserver -https=:10443' -i mywebserver . templates/

justrun -c 'make' -w -i mylib.a -i mylib.so .

find . -type d | justrun -c 'grep foobar *.h' -stdin -i .git

justrun -c 'grep foobar *.h' -stdin < <(cat filelist1 filelist2)

justrun -c 'some_expensive_op' -delay 10s .

justrun -c 'some_inexpensive_op' -delay 100ms .

Usage

$  justrun -h
justrun: help requested
usage: justrun -c 'SOME BASH COMMAND' [FILEPATH]*
  -c="": command to run when files change in given directories
  -delay=750ms: the time to wait between runs of the command if many fs events occur
  -h=false: print this help text
  -help=false: print this help text
  -i=[]: a file path to ignore events from (may be given multiple times)
  -stdin=false: read list of files to track from stdin, not the command-line
  -v=false: verbose output
  -w=false: wait for the command to finish and do not attempt to kill it
  -s=bash: shell to run the command

Compared to other tools

Justrun is perhaps best understood in terms of the other tools out there. inotify-tools is Linux only and doesn't handle process lifetime of the commands it runs (though, this may be desirable) so its difficult to make servers run well with it. fswatch similarly will wait until the command halts before running it again, and is OS X only. entr also waits until the command given finishes for re-running. devweb assumes that the command being run is a binary that takes the parameter -addr. shotgun is only capable of running Ruby Rack servers, and nothing else. nailgun requires the commands be written in Java, and are run in the nailgun server's process space instead of the user's shell.

Not all of the constraints on these other tools are bad choices.

Installing

The easiest way to install justrun is to put the justrun binary in the published zipfiles into your PATH. That's it! You can find all of the pre-built binaries at http://projects.somethingsimilar.com/justrun/downloads/

To install from source, install Go (being sure to set up a working $GOPATH, detailed in those instructions), and run:

go get github.com/jmhodges/justrun

Caveats

Justrun requires commands to handle SIGTERM as their termination signal (or one of their termination signals). It does not attempt to send SIGKILL if the processes do not shutdown "quickly" in response to a SIGTERM.

Justrun runs on *nixes only.

Justrun will always send a SIGTERM to its child processes, even if it received a SIGINT.

Justrun currently only supports the bash shell, but, with some thought, a shell configuration option could be provided. Pull requests welcome.

The -i argument is no longer required to be a comma-separated list, but it would be nice for more complicated systems to have an easier way to configure ignore lists.

It's fairly easy to accidentally cause a cycle in your commands and the filesystem watches. Files or directories that will be touched or created by your command should be added to the -i option.

If you wish to fork off subprocessses in your commands, you'll have to call setpgid(2) (or set -o monitor in the bash shell) in the commands to avoid having them terminated.

More Repositories

1

levigo

levigo is a Go wrapper for LevelDB
Go
416
star
2

opposite_of_a_bloom_filter

Implementations of a data structure with false negatives but no false positives.
Java
352
star
3

howsmyssl

The web app running howsmyssl.com
Go
340
star
4

jsonpp

A fast command line JSON pretty printer.
Go
332
star
5

copyfighter

Statically analyzes Go code and reports functions that are passing large structs by value
Go
204
star
6

rchardet

Character encoding auto-detection in Ruby. As smart as your browser. Open source.
Ruby
189
star
7

bazel_gomock

Code to create Go mocks for bazel targets using mockgen
Starlark
59
star
8

kdtree2

A kd-tree implementation in C++ (and Fortran) by Matthew B. Kennel
Fortran
56
star
9

rfeedparser

rFeedParser is a translation of the Universal Feed Parser from Python into Ruby. It has nearly the exact same behavior.
Ruby
56
star
10

clock

Package clock provides an abstraction for system time that enables testing of time-sensitive code.
Go
52
star
11

libssl

A quick git copy of the OpenBSD fork of OpenSSL No promises on updates as git cvsimport is being buggy.
C
25
star
12

minhash

An implementation of the MinHash algorithm in ruby using Murmur Hash
Ruby
23
star
13

gocld3

C++
20
star
14

grab

Downloads code repositories in a convenient directory layout
Go
20
star
15

murmur_hash

A ruby extension of the MurmurHash2 functions.
C++
18
star
16

kustomize-age

A kustomize plugin for using age encrypted files in Secrets
Go
13
star
17

componentize

MapReduce jobs to find the connected components in a large graph
Scala
10
star
18

lekube

lekube manages Kubernetes secrets with Let's Encrypt TLS certificates using HTTP
Go
8
star
19

ensure-latest-go

Ensure-latest-go is a GitHub Action to keep Dockerfiles, Travis CI configs, and GitHub Actions using the latest stable version of Go.
Go
8
star
20

ring_buffer

A lock-less ring buffer.
Java
7
star
21

ports

Some MacPorts Portfiles that are handy.
Emacs Lisp
7
star
22

vpork

Distributed hash table performance tool
Groovy
6
star
23

hover

A Go client library for the unofficial, unsupported Hover DNS API
Go
6
star
24

bloomnames

A quick and dirty bloom filter implementation
Python
6
star
25

mappoint

Talk to the MapPoint SOAP API.
Ruby
5
star
26

tommy

A general purpose Bayesian classifier.
Ruby
5
star
27

virtualearth

Talk to the VirtualEarth SOAP API.
Ruby
4
star
28

erlake

A rake task library for Erlang projects
Ruby
4
star
29

libmurmurhash

Shell
4
star
30

plus2rss

Turn Google+ user streams into RSS feeds
Go
4
star
31

build_cassandra

This is a helpful thing that builds Cassandra and Java 7 on your OS X box.
4
star
32

serve

Every Go programmer has a little HTTP file server command. This one is mine.
Go
4
star
33

rack-oauth

Rack Middleware for OAuth Authorization
Ruby
3
star
34

emacs

Emacs Lisp
3
star
35

idgen

a random uuid generator with some niceness
Go
3
star
36

fakehoe

Fakes the Hoe library. Useful for rip when installing libraries that depend on Hoe for their installation.
Ruby
3
star
37

sherlocksampling

A web app for easily estimating the number of bugs left in a piece of code
Ruby
3
star
38

handle_http

A placeholder while I get people to help me figure out to do this right
Ruby
2
star
39

nodeinfo

nodeinfo finds abnormal behavior in your syslogs
Java
2
star
40

growlme

small script to send yourself a growl notification when a command finishes
2
star
41

schmemcached

A prototype implementation of a Memcached client & server in Scala using Finagle
Scala
2
star
42

my-wordpress-sandbox

My fork of the sandbox theme to strip SomethingSimilar.com down.
PHP
2
star
43

godeps2bazel

Converts Godeps JSON dependency file entries into bazel go repositories
Go
2
star
44

keyword_prospector

Search for keywords in text and create hyperlinks
Ruby
2
star
45

twitter-edu

Exercises for twitter.edu
Ruby
2
star
46

iknowjoshstone

You should know him, too.
Ruby
1
star
47

gmail_floating_button_bar

A nice implementation of the gmail floating button bar.
JavaScript
1
star
48

goose

bitbucket.org/liamstask/goose without sqlite until bazel cgo understands tag
Go
1
star
49

xmlenum

a quick hack enumerate all tags in a (possibly large) xml file
Go
1
star
50

covid

Jupyter Notebook
1
star
51

whoownsmyavailability.com

you do
1
star
52

levigo_leveldb_1.4

levigo is a Go wrapper for LevelDB. This is a fork to support old versions of LevelDB. Prefer upgrading your LevelDB installation to using this.
Go
1
star