Skip to content

Latest commit

 

History

History
86 lines (59 loc) · 2.09 KB

README.md

File metadata and controls

86 lines (59 loc) · 2.09 KB

Process Tree

Manage your dependent processes in declarative way

Build Status

Clojars Project

Usage

Declare your processes in .lein-env in project root:

{:process-tree {:Xvfb    {:start "Xvfb :0 -screen 0 800x600x16"}
                :fluxbox {:start "fluxbox"
                          :dependencies :Xvfb}
                :skype   {:start "echo username password | skype --pipelogin"
                          :dependencies :fluxbox}
                :x11vnc  {:start "x11vnc -xkb -forever"
                          :dependencies :Xvfb}}}

then in your code just:

(process-tree.core/run :skype :x11vnc) ;; this blocks

This ensures that all dependencies are up-and-running and spawns missing processes.

You can also stop process and all dependent children by:

(process-tree.core/term :Xvfb) ;; this blocks

This would send kill -15 to all leaf-children recurcively first then their's parents and only then terminate Xvfb itself.

Your process tree configuration can be also passed directly to run/term:

;; assume cfg is as above: {:Xvfb ..., :fluxbox ...}
(process-tree.core/run :skype :x11vnc cfg)

NOTE that keys in map must match process name, if not - just name it like you want, but add :name key in it's map.

Supervising

You can also run this scheduled or just in a loop in a separate thread and achieve runit-like monitoring effect. Be sure, your processes won't be started twice and it's pretty fast check

;; assume everything is running
(time (run :x11vnc :skype)) ;;=> "Elapsed time: 0.022286 msecs"

REPL-development

(use 'process-tree.core)
(setup-dev)

Test

$ lein expectations
# or
$ lein autoexpect

License

Copyright © 2014 Vlad Bokov

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.