Passenger Max Requests on Heroku - heroku

It it possible to setup Passenger to use a PassengerMaxRequests on Heroku? From what I can tell, Heroku requires the passenger configuration to happen within a Procfile like so:
web: bundle exec passenger start -p $PORT --max-pool-size 4
I tried --max-requests but get an invalid option exception. It also doesn't appear under heroku start --help. Any way to get this parameter (or any of the other parameters from the docs) working with a Procfile?

It looks like you should follow the Passenger Standalone Advanced Configuration guide, and create an nginx config file (not apache), since it seems the standalone passenger actually just comes with nginx.
passenger start --nginx-config-template nginx.conf.erb
And then you should be able to set passenger_max_requests

Related

Phusion passenger is overriding my database config

I am using nginx with Phusion Passenger to bootload a ruby on rails application, if I run the application like
rails s -e production
It does connect correctly to the database, but when bootloaded from nginx with passenger it tries to use root to the database, like ignoring the config files.
I already tried giving permissions, but doesnt look like there is the problem, I already opened the 3 possible host names for root, which could be "localhost", "%" and "127.0.0.1", but in any case it should be openning a connection with root
I would say something is weird on how passenger behaves or that somewhere (not in the app) is ignoring the database.yml or overriding the credentials
in my opinion, I think you should try Passenger Standalone that is what I use and it works fine.

Unicorn not reading ENV variables

I'm having some issues with SECRET_KEY_BASE setting on our production Ubuntu server with Unicorn and nginx. I added the variable to .bashrc and its reading fine when I try echo $SECRET_KEY_BASE, but for some reason I'm getting the following error:
app error: Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml` (RuntimeError)
Also, when I try to access the variable with ENV["SECRET_KEY_BASE"] from within the console in production environment, I can read it fine.
I tried restarting Unicorn and server and it doesn't help. Any idea why this is happening?
You may need to add the variables to the unicorn.conf file, since it seems you are launching Unicorn with a different user or without sourcing your .bashrc.
In any case, I suggest you use dotenv gem to store your env variables in a .env file within your project. That is the cleanest way I know. If you need to have capistrano integration and handle all the different environments with ease, you can also use dotenv-deployment gem.

Procfile in Heroku

Can somebody help me regarding on how can i solve my problem on Heroku. Im new to Heroku.
This warning always appear. WARNING:No Procfile detected, using the default web server (webrick). Im using Rails 4. Thank in advance
The error itself is pretty self-explanatory. No Procfile is detected, so in your root directory create a file called Procfile.
As you stated in your comment you are using the Unicorn server so inside the Procfile put this code.
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
I am assuming you created a unicorn.rb file
push to github, push to heroku and see if that works.
The Procfile holds the command for starting the server, and any options you need to pass to that. Your app was crashing because the command to start the server was not there at all.

Rails app only pointing to default rails index page

So I am new to deploying to an Ubuntu Server (12.04). I have nginx and unicorn installed. Everything seems to be working except for the fact that I don't know how to point it to my app. Currently I am pointing to 'home/administrator/apps/my_site/current/public' however all my files are in 'home/administrator/apps/my_site/app/views/'. I am currently only pointing to the static files like the error htmls and the default rails index.html. How do I get nginx to point to my views/app?
Thanks.
If you're using Nginx + Unicorn then you don't point Nginx at any path, you run up unicorn on the server and then have Nginx proxy all it's requests to the unicorn instance. I would recommend looking at using foreman and then it's foreman export upstart which exports ubuntu upstart scripts for controlling unicorn.
This link gives you details on how to config your nginx site.

Heroku RACK_ENV says "development" on Thin, but "staging" on Unicorn

I came across this behavior and was wondering if anyone else had seen it. I have a workaround so it's not a show-stopper.
I created a new app on Heroku with a Cedar stack. When demonstrating multiple environments I added the following config var:
heroku config:add RACK_ENV=staging --app appname
I visually verified that the environment var was set, then put the following route in my simple Sinatra example:
get '/?' do
ENV['RACK_ENV']
end
When I tested locally on my laptop, I received the expected development.
When I pushed to Heroku and hit the same route on herokuapp.com I got development instead of staging.
I switched the web server from Thin to Unicorn through the Procfile and pushed the changes back up to Heroku.
Now when I hit the route, I get the expected staging.
Has anyone else seen this? My workaround on another project where I was running Thin was to key the environment off of the New Relic app name. (I didn't switch to Unicorn because I need New Relic to work and currently Cedar and New Relic and Unicorn work together).
I had the same problem with sinatra and thin on the cedar stack using heroku's example sinatra app. The RACK_ENV refuses to be set to anything but development. (Heroku seems to think that it's RACK_ENV is set, since running 'heroku config' displays the environment you set, however in the app it's always development).
The same app on the bamboo stack had no problems.
EDIT: I submitted a ticket to heroku about this and got a really quick response which fixed the bug for me:
QUOTE:
It looks like there's a small bug in our default Procfile if you're using thin. Can you create a Procfile with the following in it?
web: bundle exec thin start -R config.ru -e $RACK_ENV -p $PORT
You can also set both your RACK_ENV and RAILS_ENV to staging using the Heroku gem ... then it works as expected. I think it may be a problem with Heroku.

Resources