How to restart Phusion Passenger + Apache in Production mode on Ubuntu server for Ruby on Rails?
Asked Answered
T

4

8

I am having Apache + phusion passenger, I have put

RailsEnv production

in /etc/apache2/sites-available/default file and have restarted apache but when I am running

rails c
> Rails.env.production?

it gives fales where as for

> Rails.env.development?

it gives true. Is there any other way to restart passenger as I do think putting "RailsEnv production" in default is the right way ? btw I am using

sudo service apache2 restart

How to start my ruby on rails app in Production mode with passenger + apache ?

That answered 12/3, 2013 at 17:51 Comment(0)
T
3

Your app is probably in production mode already.

By default, rails c loads the app in dvelopment mode.

If you want your console to be launched in production mode, do the following :

RAILS_ENV=production rails c

The console and the web app are two different rails proccess and run independently.

You should check your production.log file to be sure that your app runs in production.

Tannie answered 12/3, 2013 at 17:56 Comment(2)
you are right, the development.rb only has 4 entries but the production.rb is full so the server is certainly running in production mode.That
you can also do this by typing 'rails console [environment]' e.g. rails console productionHegarty
S
27

just create a restart.txt in tmp dir of your app

e.g.

  touch %RAILS_ROOT%/tmp/restart.txt

look here http://www.modrails.com/documentation/Users%20guide%20Apache.html section 3.3

Silviasilviculture answered 12/3, 2013 at 17:56 Comment(2)
How can I be sure this has its effect (I'm reorganizing my phusion/capistrano set-up)? Or, what is this "restart" needed for anyway?Prejudicial
Ah! I can tell it restarts by watching the Apache error log file (/var/log/apache2/error.log in my case) for something like: [ 2014-01-08 20:37:38.9069 32489/7ff921f67700 Pool2/SmartSpawner.h:301 ]: Preloader for /app01/akiary_registration/app started on PID 13325, listening on unix:/tmp/passenger.1.0.32480/generation-0/backends/preloader.13325Prejudicial
T
3

Your app is probably in production mode already.

By default, rails c loads the app in dvelopment mode.

If you want your console to be launched in production mode, do the following :

RAILS_ENV=production rails c

The console and the web app are two different rails proccess and run independently.

You should check your production.log file to be sure that your app runs in production.

Tannie answered 12/3, 2013 at 17:56 Comment(2)
you are right, the development.rb only has 4 entries but the production.rb is full so the server is certainly running in production mode.That
you can also do this by typing 'rails console [environment]' e.g. rails console productionHegarty
D
3

Just for starting app with particular port use below command:

passenger start -a 0.0.0.0 -p 3000 -d -e production

Dysphonia answered 12/11, 2013 at 12:35 Comment(0)
S
3

I followed the commands listed in PhusionPassenger docs here and they worked straight-away.

deployer@staging:~$ passenger-config restart-app
Please select the application to restart.
Tip: re-run this command with --help to learn how to automate it.
If the menu doesn't display correctly, press '!'

 ‣   /home/deployer/myapp/current (staging)
     /home/deployer/myapp_2/current (staging)
     Cancel

Restarting /home/deployer/myapp/current (staging)

deployer@staging:~$ passenger-config restart-app
Please select the application to restart.
Tip: re-run this command with --help to learn how to automate it.
If the menu doesn't display correctly, press '!'

     /home/deployer/myapp/current (staging)
 ‣   /home/deployer/myapp_2/current (staging)
     Cancel

Restarting /home/deployer/myapp_2/current (staging)
Stefan answered 16/3, 2018 at 7:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.