sinatra: Error deploying Rails 5 app with Sinatra 2.0.0beta2 to Amazon Linux AMI
I have a Rails app that is running successfully on Rails 4.2 with Ruby 2.3 and Sinatra 1.0 and Puma 3.6.0.
I use Sinatra because of the gem “Delayed Job Web” which has it as a dependency. I am upgrading my app to to Rails 5.0.0.1, and Sinatra to 2.0.0.beta2 for Rails 5 compatibility. Puma is still 3.6.0.
I host the app at AWS with Elastic Beanstalk. My app runs fine locally with Rails 5 and Sinatra 2.0.0.beta2, but when I deploy it to Elastic Beanstalk, I see an error in the puma log during restarts as shown below, though aside from this, the app runs as expected.
Based on the stack trace, it looks like a directory that is being passed to Sinatra no longer exists at the time it’s needed. However, this same issue didn’t happen with Rails 4.2 and Sinatra 1.0 on the same machine and same version of the Amazon Linux AMI, so I’m not sure what’s causing it.
I’m new to Sinatra, so any advice would be appreciated. If this is the wrong place to file this issue, I can also post it on Stack Overflow. Thanks.
Stack trace is:
Aug 23 20:29:16 puma.log: === puma startup: 2016-08-24 03:29:16 +0000 ===
Aug 23 20:29:23 puma.log: [9376] - Worker 0 (pid: 9379) booted, phase: 0
Aug 24 08:39:03 puma.log: [9376] - Gracefully shutting down workers...
Aug 24 08:39:05 puma.log: /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/sinatra-2.0.0.beta2/lib/sinatra/main.rb:11:in `expand_path': No such file or directory - getcwd (Errno::ENOENT)
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/sinatra-2.0.0.beta2/lib/sinatra/main.rb:11:in `block in <class:Application>'
Aug 24 08:39:05 puma.log: from (eval):1:in `run?'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/sinatra-2.0.0.beta2/lib/sinatra/main.rb:26:in `block in <module:Sinatra>'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cluster.rb:120:in `fork'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cluster.rb:120:in `block in spawn_workers'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cluster.rb:116:in `times'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cluster.rb:116:in `spawn_workers'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cluster.rb:426:in `run'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/launcher.rb:172:in `run'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cli.rb:74:in `run'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/bin/puma:10:in `<top (required)>'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/bin/puma:23:in `load'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/bin/puma:23:in `<top (required)>'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/cli/exec.rb:63:in `load'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/cli/exec.rb:63:in `kernel_load'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/cli/exec.rb:24:in `run'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/cli.rb:304:in `exec'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/cli.rb:11:in `start'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/exe/bundle:27:in `block in <top (required)>'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/exe/bundle:19:in `<top (required)>'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/bin/bundle:23:in `load'
Aug 24 08:39:05 puma.log: from /opt/rubies/ruby-2.3.1/bin/bundle:23:in `<main>'
Aug 24 08:39:05 puma.log: [9376] === puma shutdown: 2016-08-24 15:39:05 +0000 ===
Aug 24 08:39:05 puma.log: [9376] - Goodbye!```
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 29 (12 by maintainers)
@wfried Add
require: falseto yourgem 'sinatra'statement. That should do the trick. delayed_job_web willrequire 'sinatra/base'when it loads.Reading the stack trace, it looks like the
at_exithandler in Sinatra::Application is firing on graceful Puma shutdown. Normally this isn’t a problem because the:runproc evals false sorun!doesn’t fire. In this case, the:runproc fails because the working directory goes away on redeploy.Taking a step back, one might ask why Sinatra::Application (sinatra/main) is being loaded in the first place. DelayedJobWeb is developed as a modular Sinatra application, subclassing Sinatra::Base (sinatra/base). Sinatra::Application is only being loaded because default behavior of the Sinatra gem is to require sinatra/main! You essentially have a second Sinatra application loaded in your environment, in addition to DelayedJobWeb, sitting on an
at_exithook, for no other purpose than to ruin your day.Telling Bundler not to require sinatra/main (or anything else) and letting delayed_job_web require sinatra/base is the best solution here.