Skip to content

Instantly share code, notes, and snippets.

@andykingking
Last active December 28, 2015 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andykingking/7423897 to your computer and use it in GitHub Desktop.
Save andykingking/7423897 to your computer and use it in GitHub Desktop.
Quick script to start certain services for development
require 'sys/proctable'
module ProcTableGrep
def exist?
Sys::ProcTable.ps.each do |p|
return true if p.cmdline.include? @pgrep
end
false
end
end
module VMGrep
def exist?
result = `/Applications/VMware\\ Fusion.app/Contents/Library/vmrun list`
result.include? @pgrep
end
end
class ReqProcess
def initialize(name, pgrep, cmd, is_vmware=false)
@name = name
@pgrep = pgrep
@cmd = cmd
unless is_vmware
extend ProcTableGrep
else
extend VMGrep
end
end
def daemonize
fork {`#{@cmd}`}
puts "Started #{@name}."
end
end
processes = []
# Add processes
processes.each {|p| p.daemonize unless p.exist?}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment