0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
A collection of utility methods to run shell commands for Runfile
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 0.2
 Project Readme

Runfile Exec

Gem Version

Runfile extensions for executing shell commands.


Deprecation Notice:
This gem is being phased out. It has been merged directly into Runfile so there is no longer a need for you to include it.


Install

$ gem install runfile-exec

Usage

Put this in your Runfile

require "runfile-exec"

And then you can use any of these commands in your Runfile actions:

# Print and run a command. Wait until it is done and continue.
run 'pwd'

# Print and run a command. Wait until it is done and exit.
run! 'pwd'

# Run a command in the background
run_bg 'some/long-running/process'

# Run a command in the background, log to a log file and save the process 
# ID in a pid file for later reference
run_bg 'some/long-running/process', log: 'my.log', pid: 'daemon'

# Stop a command started with 'run_bg'. Provide the name of he pid file you 
# used in 'run_bg'
stop_bg 'daemon'

# Intercept each call before executed. Can be used to modify the command, run
# something before it, or cancel it altogether.
# Your block receives the command as argument, and should return a command to
# run or false to stop execution.
before_run do |command|
  cmd.gsub /^(rails|rake|cucumber)/, "bin/\\1"
end

# Intercept each call before it exits. Note this is only useful with `run` and
# `run_bg` but not with `run!` which exits after execution.
after_run do |command|
  puts "Finished #{command}"
end

About PID files

PID files are stored in the working directory by default. To change the location, add this at the beginning of your Runfile:

RunfileExec.pid_dir = './tmp'

Example

See the example folder for sample usage. To see the output:

$ cd example
$ run         # list commands
$ run runbg   # start one of the sample commands