Closed
Description
The suggested configuration here:
Line 42 in 77e05e3
... will cause an Errno::EADDRINUSE
error to be raised if a lambda is invoked manually, because the LambdaPunch
server will have already been started. A call to aws lambda invoke
for example yields the following error and stack trace:
Address already in use - bind(2) for "127.0.0.1" port 9030
/usr/local/lib/ruby/2.7.0/drb/drb.rb:883:in 'initialize':
Address already in use - bind(2) for "127.0.0.1" port 9030 (Errno::EADDRINUSE)
from /usr/local/lib/ruby/2.7.0/drb/drb.rb:883:in 'open'
from /usr/local/lib/ruby/2.7.0/drb/drb.rb:883:in 'open_server'
from /usr/local/lib/ruby/2.7.0/drb/drb.rb:766:in 'block in open_server'
from /usr/local/lib/ruby/2.7.0/drb/drb.rb:764:in 'each'
from /usr/local/lib/ruby/2.7.0/drb/drb.rb:764:in 'open_server'
from /usr/local/lib/ruby/2.7.0/drb/drb.rb:1466:in 'initialize'
from /usr/local/lib/ruby/2.7.0/drb/drb.rb:1772:in 'new'
from /usr/local/lib/ruby/2.7.0/drb/drb.rb:1772:in 'start_service'
from /app/vendor/bundle/ruby/2.7.0/gems/lambda_punch-1.0.3/lib/lambda_punch/server.rb:22:in 'initialize'
from /usr/local/lib/ruby/2.7.0/singleton.rb:125:in 'new'
from /usr/local/lib/ruby/2.7.0/singleton.rb:125:in 'block in instance'
from /usr/local/lib/ruby/2.7.0/singleton.rb:123:in 'synchronize'
from /usr/local/lib/ruby/2.7.0/singleton.rb:123:in 'instance'
from /app/vendor/bundle/ruby/2.7.0/gems/lambda_punch-1.0.3/lib/lambda_punch/server.rb:15:in 'start!'
from /app/vendor/bundle/ruby/2.7.0/gems/lambda_punch-1.0.3/lib/lambda_punch.rb:36:in 'start_server!'
from /app/config/environments/production.rb:141:in 'block (2 levels) in <main>'
I was able to work around this doing something like the following:
config.to_prepare do
LambdaPunch.start_server!
rescue Errno::EADDRINUSE => e
Rails.logger.info("LambdaPunch is already running! (#{e.class})")
end
Is there a better way to do this, or is there something that LambdaPunch
can support natively to check to see if a server is already running, e.g. an alive?
predicate similar to what's in DRb
?
Metadata
Metadata
Assignees
Labels
No labels