Top Level Namespace
Defined Under Namespace
Modules: ClassInheritableAttributes, Doozer, FSWatcher, Paginate, ServiceState Classes: Array, Class, DateTime, FalseClass, FileSystemWatcher, NilClass, Numeric, Object, Symbol, Time, TrueClass
Constant Summary collapse
- DOOZER_PATH =
File.(File.dirname(__FILE__))
- APP_PATH =
Dir.pwd
- PAGINATE_PLUGIN_ROOT =
File.join(File.dirname(__FILE__), 'lib')
Instance Method Summary collapse
- #copy(path, force) ⇒ Object
- #file_to_task(f, args = nil) ⇒ Object
- #freeze(gem_name, version, force) ⇒ Object
- #git(path, version, force) ⇒ Object
-
#md5 ⇒ Object
taken from: paulhorman.com/filesystemwatcher/.
-
#restart ⇒ Object
Calls stop() and then start().
-
#restart_unicorn ⇒ Object
Calls stop_unicorn() and then start_unicorn().
-
#start ⇒ Object
development: Only starts the first configured (if more then one) address:port.
-
#start_unicorn ⇒ Object
Call to start unicorn server.
-
#stop ⇒ Object
development: Only stops the first configured (if more then one) address:port.
-
#stop_unicorn ⇒ Object
development: Only stops the first configured (if more then one) address:port.
-
#test ⇒ Object
Automatically starts a test instance of your appserver on localhost:5000.
Instance Method Details
#copy(path, force) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/doozer/scripts/plugin.rb', line 89 def copy(path, force) if File.directory?("#{path}") cp_to_path = "#{APP_PATH}/gems/" if path.index('doozer') cp_to_path += 'doozer' else cp_to_path += 'plugins' end puts "=> Copying: #{path}..." puts "=> To: #{cp_to_path}" system("cp -R #{'-f' if force} #{path} #{cp_to_path}") puts "=> Completed!" puts "=> Don't forget to initialize your plugin in gems/plugins/init.rb" else puts "ERROR => #{path} doesn't appear to be a valid path" end end |
#file_to_task(f, args = nil) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/doozer/scripts/task.rb', line 64 def file_to_task(f, args=nil) require f file_name = f.split("/").last.gsub(/\.rb/,"") klass = Doozer::Lib.classify(file_name) return Object.const_get(klass).new(args), file_name end |
#freeze(gem_name, version, force) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/doozer/scripts/plugin.rb', line 53 def freeze(gem_name, version, force) # locate the gem to freeze puts "Freezing gem..." path = `gem which #{gem_name} -a` source = gem_name if path.downcase.index('can\'t find') puts path exit end path.gsub!(/\n/, '') gem_path = nil if version name = "#{gem_name}-#{version}" # check if the return from the which statement is actually the correct gem if path.index(name) gem_path=path.split(name)[0] else # attempt to locate the gem+version specified gem_path = path.split(gem_name)[0] if not File.directory?("#{gem_path}#{name}") puts "=> Can't find #{gem_path}#{name}" system("gem list #{gem_name}") exit end end gem_name = name end if gem_path.nil? parts = path.split(gem_name) gem_path = parts[0] gem_name += parts[1].split('/')[0] end gem_path += gem_name copy(gem_path, force) end |
#git(path, version, force) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/doozer/scripts/plugin.rb', line 39 def git(path, version, force) puts "Checking out remote git repo..." name = path.split('/').last.gsub(/\.git/,'') name += "-#{version}" if version plugin_dir = "#{APP_PATH}/gems/plugins" plugin = "#{plugin_dir}/#{name}" puts "=> #{path} to #{plugin}" system("rm -rf #{plugin}") if force system("git clone #{path} #{plugin}") if version system("cd #{plugin}; git checkout #{version}") end end |
#md5 ⇒ Object
taken from: paulhorman.com/filesystemwatcher/
2 |
# File 'lib/doozer/watcher.rb', line 2 require "md5" |
#restart ⇒ Object
Calls stop() and then start()
88 89 90 91 |
# File 'lib/doozer/scripts/cluster.rb', line 88 def restart stop start end |
#restart_unicorn ⇒ Object
Calls stop_unicorn() and then start_unicorn()
94 95 96 97 |
# File 'lib/doozer/scripts/cluster.rb', line 94 def restart_unicorn stop_unicorn start_unicorn end |
#start ⇒ Object
development: Only starts the first configured (if more then one) address:port
deployment: Automatically starts a new instance of your appserver for each defined cluster address:port
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/doozer/scripts/cluster.rb', line 43 def start puts "Starting clusters..." for app in @apps if @env == :deployment #need to check if application has a pid file so we don't start pid_file = "#{APP_PATH}/log/doozer.#{app[:port]}.pid" raise "pid file already exists for #{pid_file}" if File.exist?(pid_file) cmd = "rackup #{@config} -p #{app[:port]} -E #{@env.to_s} -s #{@server} -o #{app[:ip]} #{@daemonize} -P #{pid_file}" puts "=> #{cmd}" system(cmd) else cmd = "rackup #{@config} -p #{app[:port]} -E #{@env.to_s} -s #{@server} -o #{app[:ip]}" puts "=> #{cmd}" system(cmd) break end end puts "Did they start?" system("ps -aux | grep rackup") end |
#start_unicorn ⇒ Object
Call to start unicorn server
Set the app.yml clusters server to unicorn complete with one ip:port value.
You can also pass an optional value -c FILE to override the default unicorn conf.
See Unicorn::Configurator for more details => unicorn.bogomips.org/Unicorn/Configurator.html
See this page for supported signals => unicorn.bogomips.org/SIGNALS.html
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/doozer/scripts/cluster.rb', line 73 def start_unicorn puts "Starting unicorn..." for app in @apps # unicorn @config_file = "-c #{@config_file}" if @config_file != '' cmd = "unicorn -p #{app[:port]} -E #{@env.to_s} -o #{app[:ip]} #{@daemonize} #{@config_file} #{@config}" puts "=> #{cmd}" system(cmd) break end puts "Did they start?" system("ps -aux | grep unicorn") end |
#stop ⇒ Object
development: Only stops the first configured (if more then one) address:port
deployment: Automatically stops all instances of your appserver for each defined cluster address:port
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/doozer/scripts/cluster.rb', line 102 def stop system("ps -aux | grep rackup") puts "Stoping clusters..." for app in @apps if @env == :deployment pid_file = "#{APP_PATH}/log/doozer.#{app[:port]}.pid" puts "=> Reading pid from #{pid_file}" if File.exist?(pid_file) File.open(pid_file, 'r'){ | f | pid = f.gets.to_i puts "=> Shutting down process #{pid}" system("kill -9 #{pid}") } File.delete(pid_file) else puts "ERROR => pid file doesn't exist" end end end sleep(1) system("ps -aux | grep rackup") end |
#stop_unicorn ⇒ Object
development: Only stops the first configured (if more then one) address:port
deployment: Automatically stops the first master process/cluster defined for address:port
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/doozer/scripts/cluster.rb', line 129 def stop_unicorn system("ps -aux | grep unicorn") puts "Stoping unicorn..." for app in @apps if @env == :deployment pid_file = "#{APP_PATH}/log/unicorn.pid" puts "=> Reading pid from #{pid_file}" if File.exist?(pid_file) system("kill -QUIT `cat #{pid_file}`") else puts "ERROR => pid file doesn't exist" end end break end sleep(1) system("ps -aux | grep unicorn") end |
#test ⇒ Object
Automatically starts a test instance of your appserver on localhost:5000. (No -E flag is required for this command).
34 35 36 37 38 |
# File 'lib/doozer/scripts/cluster.rb', line 34 def test cmd = "rackup #{@test_config}" puts "=> #{cmd} -p 5000 -E test -o 127.0.0.1" system(cmd) end |