0
votes

I deployed a Rails 4 app ( using .rbenv ) to a remote Ubuntu server running Ngninx + Unicorn using Capistrano ( staging deployment)

E, [2015-08-10T16:53:29.822778 #24117] ERROR -- : app error: Missing `secret_token` and `secret_key_base` for 'staging' environment, set these values in `config/secrets.yml` (RuntimeError)

Using the capistrano/upload-config , I link the secrets.yml file on the remote server in the current release deployed

app/config/
 secrets.staging.yml
 secrets.yml -> /var/www/rails/delayMessage/shared/config/secrets.yml

and the /var/www/rails/delayMessage/shared/config/secrets.yml file contains

staging:
   secret_key_base: 10c7ed6bccc6d3acb71...

Why is the secret_key_base NOT taken into account, and why is this error raised and displayed in the unicorn.stderr.log

UPDATE 1

in unicorn.rb I have the following paths (app and shared ) set ... maybe they are wrong

# Set your full path to application. app_dir = File.expand_path('../../', FILE) shared_dir = File.expand_path('../../../shared/', FILE)

1
What is secrets.staging.yml? is it another file in app/configbigsolom
I've personally never used Unicorn, so I'm stabbing in the dark. But, I'd confirm that Unicorn is looking at the right directory. For example, since Capistrano points current at releases/[timestamp], Unicorn might be pointing at an old version. Alternately, make sure that Unicorn is being restarted after the symlink change so it sees the file (I'd imagine that this is happening correctly).will_in_wi
Thanks for your feedback ... I'll have a look to this Unicorn pointing path... I updated my post with the current paths for app dir and shared dir if not using Unicorn , which web server are you using ? ( Passenger or Puma ..) With previous rails app I used Apache+Passenger, .. I may come back to Nginx+Passenger , it seems the latest Fusion-Passenger version ( called 'raptor' is 5X faster than Unicorn....user762579
I forgot to require capistrano-rbenv ...user762579

1 Answers

0
votes

I had a similar situation, but, .rbenv was not on my list. My solution was actually, pretty easy. First I stopped unicorn (not only restart), I mean, really stop it with the following

sudo service unicorn_myapp force-stop

And also stopped the Nginx:

sudo service nginx stop

Then ran the:RAILS_ENV=environment rake secret copied the value into the staging section in /deployed_app/shared/config/secrets.yml and then, restarted all again with

sudo service unicorn_myapp start
sudo service nginx start

And all is back on track again...

Hope it helps