added services
This commit is contained in:
0
services/lib/tasks/.keep
Normal file
0
services/lib/tasks/.keep
Normal file
46
services/lib/tasks/consumer.rake
Normal file
46
services/lib/tasks/consumer.rake
Normal file
@ -0,0 +1,46 @@
|
||||
namespace :consumer do
|
||||
task start: :environment do
|
||||
service_name = 'BetterMail::Consumer'
|
||||
# Create a new server instance for listening at localhost interfaces 127.0.0.1:2525
|
||||
# and accepting a maximum of 4 simultaneous connections per default
|
||||
service = Bettermail::Consumer.new
|
||||
|
||||
# save flag for Ctrl-C pressed
|
||||
flag_status_ctrl_c_pressed = false
|
||||
|
||||
# try to gracefully shutdown on Ctrl-C
|
||||
trap('INT') do
|
||||
# print an empty line right after ^C
|
||||
puts
|
||||
# notify flag about Ctrl-C was pressed
|
||||
flag_status_ctrl_c_pressed = true
|
||||
# signal exit to app
|
||||
exit 0
|
||||
end
|
||||
|
||||
# Output for debug
|
||||
puts("Starting #{service_name}")
|
||||
|
||||
# setup exit code
|
||||
at_exit do
|
||||
# check to shutdown connection
|
||||
if service
|
||||
# Output for debug
|
||||
puts('Ctrl-C interrupted, exit now...') if flag_status_ctrl_c_pressed
|
||||
# info about shutdown
|
||||
puts("Shutdown #{service_name}...")
|
||||
# stop all threads and connections gracefully
|
||||
service.stop
|
||||
end
|
||||
|
||||
# Output for debug
|
||||
puts "#{service_name} stopped!"
|
||||
end
|
||||
|
||||
# Start the server
|
||||
service.start
|
||||
|
||||
# Run on server forever
|
||||
service.join
|
||||
end
|
||||
end
|
58
services/lib/tasks/proxy.rake
Normal file
58
services/lib/tasks/proxy.rake
Normal file
@ -0,0 +1,58 @@
|
||||
namespace :proxy do
|
||||
task start: :environment do
|
||||
# Create a new server instance for listening at localhost interfaces 127.0.0.1:2525
|
||||
# and accepting a maximum of 4 simultaneous connections per default
|
||||
service = Bettermail::Proxy.new(
|
||||
ports: ENV['PROXY_PORTS'],
|
||||
hosts: ENV['PROXY_HOSTS'],
|
||||
max_processings: 10,
|
||||
auth_mode: :AUTH_REQUIRED,
|
||||
tls_mode: :TLS_REQUIRED,
|
||||
tls_cert_path: './ssl/cert.pem',
|
||||
tls_key_path: './ssl/key.pem'
|
||||
)
|
||||
|
||||
service_name = 'BetterMail::SMTPProxy'
|
||||
# Create a new server instance for listening at localhost interfaces 127.0.0.1:2525
|
||||
# and accepting a maximum of 4 simultaneous connections per default
|
||||
|
||||
# save flag for Ctrl-C pressed
|
||||
flag_status_ctrl_c_pressed = false
|
||||
|
||||
# try to gracefully shutdown on Ctrl-C
|
||||
trap('INT') do
|
||||
# print an empty line right after ^C
|
||||
puts
|
||||
# notify flag about Ctrl-C was pressed
|
||||
flag_status_ctrl_c_pressed = true
|
||||
# signal exit to app
|
||||
exit(0)
|
||||
end
|
||||
|
||||
# Output for debug
|
||||
puts("Starting #{service_name}")
|
||||
|
||||
# setup exit code
|
||||
at_exit do
|
||||
# check to shutdown connection
|
||||
if service
|
||||
# Output for debug
|
||||
puts('Ctrl-C interrupted, exit now...') if flag_status_ctrl_c_pressed
|
||||
# info about shutdown
|
||||
puts("Shutdown #{service_name}...")
|
||||
# stop all threads and connections gracefully
|
||||
service.stop
|
||||
end
|
||||
|
||||
# Output for debug
|
||||
puts "#{service_name} stopped!"
|
||||
end
|
||||
|
||||
# Start the server
|
||||
service.start
|
||||
|
||||
# Run on server forever
|
||||
service.join
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user