Class: SesProxy::StartCommand
- Inherits:
-
Clamp::Command
- Object
- Clamp::Command
- SesProxy::StartCommand
- Defined in:
- lib/ses_proxy/main_command.rb
Constant Summary collapse
- @@env =
"development"
Instance Method Summary collapse
- #default_http_address ⇒ Object
- #default_http_port ⇒ Object
- #default_smtp_host ⇒ Object
- #default_smtp_port ⇒ Object
- #execute ⇒ Object
Instance Method Details
#default_http_address ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/ses_proxy/main_command.rb', line 43 def default_http_address if SesProxy::Conf.get[:http] and SesProxy::Conf.get[:http][:host] SesProxy::Conf.get[:http][:host] else "0.0.0.0" end end |
#default_http_port ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/ses_proxy/main_command.rb', line 34 def default_http_port if SesProxy::Conf.get[:http] and SesProxy::Conf.get[:http][:port] SesProxy::Conf.get[:http][:port] else 9292 end end |
#default_smtp_host ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/ses_proxy/main_command.rb', line 25 def default_smtp_host if SesProxy::Conf.get[:smtp] and SesProxy::Conf.get[:smtp][:host] SesProxy::Conf.get[:smtp][:host] else "0.0.0.0" end end |
#default_smtp_port ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/ses_proxy/main_command.rb', line 16 def default_smtp_port if SesProxy::Conf.get[:smtp] and SesProxy::Conf.get[:smtp][:port] SesProxy::Conf.get[:smtp][:port] else 1025 end end |
#execute ⇒ Object
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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/ses_proxy/main_command.rb', line 62 def execute check_for_config_file config_file check_for_mongoid_config_file mongoid_config_file @@env = environment Mongoid.load! mongoid_config_file, @@env app = Rack::Builder.new do use Rack::Reloader, 0 if @@env.eql?"development" map "/sns_endpoint" do run SesProxy::SnsEndpoint.new end run Sinatra::Application end.to_app = {:app=>app, :environment=>environment, :server=>"thin", :Port=>http_port, :Host=>http_address} server = Rack::Server.new if demonize? = {:app_name => "ses_proxy", :dir_mode=>:normal, :dir=>pid_dir, :multiple=>true} group = Daemons::ApplicationGroup.new('ses_proxy', ) [:mode] = :proc [:proc] = Proc.new { EM.run{ SesProxy::SmtpServer.start smtp_host, smtp_port } } pid = Daemons::PidFile.new pid_dir, "ses_proxy_smtp" @smtp = Daemons::Application.new(group, , pid) [:proc] = Proc.new { server.start } pid = Daemons::PidFile.new pid_dir, "ses_proxy_http" @http = Daemons::Application.new(group, , pid) @smtp.start @http.start else @smtp = Thread.new do EM.run{ SesProxy::SmtpServer.start smtp_host, smtp_port } end @http = Thread.new do server.start end @smtp.join @http.join end end |