Class: ToasterAppService
- Inherits:
-
XMLRPC::Server
- Object
- XMLRPC::Server
- ToasterAppService
- Defined in:
- lib/toaster/toaster_app_service.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ ToasterAppService
constructor
A new instance of ToasterAppService.
- #start ⇒ Object
Constructor Details
#initialize(*args) ⇒ ToasterAppService
Returns a new instance of ToasterAppService.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/toaster/toaster_app_service.rb', line 80 def initialize(*args) super(*args) @app = Toaster::ToasterApp.new @methods = ["chefsolo", "clean", "download", "exec", "lxc", "proto", "runchef", "runtest", "runtests", "testinit", "time" ] @methods.each do |method| add_handler(method) { |*args| exception = nil out = capture_stdout do begin @app.send(method, *args) rescue Object => ex exception = ex end end if exception puts "#{exception} - #{exception.backtrace.join("\n")}" puts "stdout: #{out}" puts "-----" raise exception end out } end end |
Class Method Details
.service_started? ⇒ Boolean
110 111 112 113 |
# File 'lib/toaster/toaster_app_service.rb', line 110 def self.service_started?() output = `ps aux | grep -v "ps aux" | grep ruby | grep toaster_app_service` return output.strip != "" end |
.start_service ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/toaster/toaster_app_service.rb', line 115 def self.start_service() if !service_started?() dir = File.(File.dirname(__FILE__)) Util.write("/tmp/toaster.service.loop.sh", "#!/bin/bash\n " + "cd #{dir}\n " + "while [ 1 ]; do\n " + "ruby toaster_app_service.rb do_start_service -v\n " + "done", true) `chmod +x /tmp/toaster.service.loop.sh` cmd = "cd #{dir} && screen -m -d bash /tmp/toaster.service.loop.sh" puts "INFO: Starting test service in the background (using screen), using port #{$service_port}." `#{cmd}` else puts "INFO: Another test service instance is already running on this host." end end |
Instance Method Details
#start ⇒ Object
106 107 108 |
# File 'lib/toaster/toaster_app_service.rb', line 106 def start() serve() end |