HouseTrip/rufus-runner — pull request #1 by kratob (2013-07-22 12:50:34+00:00)
Title: Feature: Fork jobs

This PR is a bit on the larger side, but can probably be reviewed easily enough commit by commit.
If need be, I could split it into several smaller PRs, but I'd rather save the effort, if not necessary.

Requirements:

> Problem:
> Errands run in thread can still fuck up the whole scheduler
>
> Solution:
> - Add a :fork => :thread | :process option to the runner DSL
> - Make it default (keep the threading variant)
> - When forking a process, and AR is present, reconnect after the fork
> - Forked processes to report success/failure through their exit status (0 = success)
> - Logging content unchanged, but add file locking around logging + flushing (to avoid partial/cluttered log lines)
> - Timeout management handled in the master process, which should send SIGKILL on timeout
>
> Locking:
> - create a lockfile /tmp/rufus-.lock
> - lock it (File.flock) whenever preparing to write a log line
> - unlock it afterwards