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
102
103
104
105
106
107
108
109
110
111
112
|
# 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
if @@env.eql?"development"
Mongoid.logger.level = Logger::DEBUG
Mongo::Logger.logger.level = Logger::DEBUG if defined?(Mongo)
else
Mongoid.logger.level = Logger::INFO
Mongo::Logger.logger.level = Logger::INFO if defined?(Mongo)
end
ses = AWS::SimpleEmailService.new(SesProxy::Conf.get[:aws])
VerifiedSender.update_identities ses.client
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
options = {:app=>app, :environment=>environment, :server=>"thin", :Port=>http_port, :Host=>http_address}
server = Rack::Server.new options
SesProxy::SmtpServer.parms = {:auth => :required}
if demonize?
options = {:app_name => "ses_proxy", :dir_mode=>:normal, :dir=>pid_dir}
group = Daemons::ApplicationGroup.new('ses_proxy', options)
options[:mode] = :proc
options[:proc] = Proc.new { EM.run{ SesProxy::SmtpServer.start smtp_host, smtp_port } }
pid = Daemons::PidFile.new pid_dir, "ses_proxy_num.0"
@smtp = Daemons::Application.new(group, options, pid)
options[:proc] = Proc.new { server.start }
pid = Daemons::PidFile.new pid_dir, "ses_proxy_num.1"
@http = Daemons::Application.new(group, options, pid)
@smtp.start
@http.start
else
EM.run do
SesProxy::SmtpServer.start smtp_host, smtp_port
server.start
trap(:INT) {
SesProxy::SmtpServer.stop
EM.stop
}
end
end
end
|