I just moved my rails app to a new machine. I'm using apache 2.2.3 and passenger 3.0.11. After initial load of the databases, I'm intermittently seeing an error that says the rails app failed to start. Here's what I see in my apache error log:
[Sun Mar 18 04:02:13 2012] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations
[ pid=10788 thr=47366521234240 file=ext/apache2/Hooks.cpp:860 time=2012-03-18 08:51:10.215 ]: Unexpected error in mod_passenger: Cannot connect to Unix socket '/tmp/passenger.1.0.13044/generation-0/socket': No such file or directory (2)
Backtrace:
in 'Passenger::ApplicationPool::Client* Passenger::ApplicationPool::Client::connect(const std::string&, const std::string&, const Passenger::StaticString&)' (Client.h:438)
in 'Passenger::ApplicationPool::Client* Hooks::getApplicationPool()' (Hooks.cpp:266)
in 'Passenger::SessionPtr Hooks::getSession(const Passenger::PoolOptions&)' (Hooks.cpp:292)
in 'int Hooks::handleRequest(request_rec*)' (Hooks.cpp:561)
I've done some googling but I can only seem to find the passenger guy saying to upgrade passenger to version 3, but I'm already on version 3. I also saw somebody saying to change the logrotate script to restart apache rather than reload, which did nothing for me. Does anybody have any ideas? Here's my apache conf for passenger. I'm using an rvm version of ruby enterprise and passenger installed as a gem:
LoadModule passenger_module /usr/local/rvm/gems/ree-1.8.7-2012.02/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ree-1.8.7-2012.02/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ree-1.8.7-2012.02/ruby
I've also tried adding rails spawn method as conservative and adding a max pool size, with the same results. Not sure where to turn.
Do you have SELinux enabled? Run cat /selinux/enforce to find out. If it prints 1, try disabling SELinux with echo 0 > /selinux/enforce to see if that solves the problem . If that fixes the problem, you can choose to try to work around it (e.g. by setting the PassengerTempDir setting. Search for SELinux in the Passenger user guide) or leave it turned off permanently.
Recently I had the same problem. I tried:
sudo /etc/init.d/httpd restart
Stopping httpd: [FAILED]
Starting httpd: (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
[FAILED]
As last solution you always can "really" restart everything:
sudo killall httpd # <---------
sudo service httpd status
httpd is stopped
sudo service httpd start
Starting httpd: [ OK ]
Related
I'm running a Rails application (ruby 2.4.4, rails 4.2) using Phusion Passenger and nginx. This application was previously running fine.
After running:
sudo apt-get update
sudo apt-get upgrade
and as a result upgrading Phusion Passenger to 5.3.0, the application fails to start when I visit the web page, and I get this in the log:
App 12172 output: Assertion failed! src/agent/SpawnEnvSetupper/SpawnEnvSetupperMain.cpp:756: void execNextCommand(const Passenger::SpawnEnvSetupper::Context&, const string&): !shell.empty()
[ E 2018-05-11 17:43:00.0707 1144/T108 age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /var/www/<app>/current: The application process exited prematurely.
Error ID: e8a7e2db
Error details saved to: /tmp/passenger-error-iL7WYm.html
[ E 2018-05-11 17:43:00.0742 1144/T8 age/Cor/Con/CheckoutSession.cpp:276 ]: [Client 1-130] Cannot checkout session because a spawning error occurred. The identifier of the error is e8a7e2db. Please see earlier logs for details about the error.
Any ideas?
Actually I think I found the cause here. The key was the !shell.empty() at the end of the error line.
I checked /etc/passwd and found that there was no shell defined for the user which Passenger runs under. In my case, this user is deploy, so I did:
sudo usermod -s /bin/bash deploy
sudo service nginx restart
This fixed the problem and now the app starts correctly.
The deployment was successful and everything is green. But when we try to access the application URL, it gives 502 Bad Gateway error.
Checking for puma process with ps -aux | grep puma doesn't return any process attached to puma server but pgrep returns following.
$pgrep -fl puma
18009 su -s /bin/bash -c bundle exec puma -C /opt/elasticbeanstalk/support/conf/pumaconf.rb webapp
18031 ruby /opt/rubies/ruby-2.0.0-p598/bin/puma -C /opt/elasticbeanstalk/support/conf/pumaconf.rb
I have tried all possible combinations, as shown in every other forum/blog OR support sites of nginx/puma. Following is the status.
Default configuration - Where we have UNIX:// sock file used in the UPSTREAM option of nginx.conf and pumaconf.rb - This gives 502 bad gatway. When checked, puma is not running and it is rebooting every 3rd minute.
As we have used it in DigitalOcean - Change the above UPSTREAM conf URL to tcp://127.0.0.1:3000 in pumaconf.rb and 127.0.0.1:3000 in conf.d/webapp.conf file. - This is also not working, puma is not able to run properly same as above.
My question is,
Why there is no control over running puma with diff. configurations? And why we have to always use the UI, which is not able to run the services properly as per other standard configuration options?
There is no configuration options from UI, to change/verify from the UI. So we have to do it from SSH. But, we have no control over rebooting PUMA from console.
Whenever puma is not running, we are not able to see any logs of what error it is facing. This is really not helpful at all.
Puma is not able to run even with default configurations, so it nginx is not able to talk to Puma and so the EC2 does not really make sense!
Please let us know, how we can resolve this issue, if you have any idea on this.
See this - https://forums.aws.amazon.com/thread.jspa?messageID=608148򔞔
Still no answers on this one, this is like our hands are cuffed and not able to change any configurations!
UPDATE
AWS is somehow stopping and starting PUMA, because i can see the process IDs changing when checking with ps -ef|grep puma. So, I started the puma to work on another port and tried to check if it runs or not.
Started on another port, and then from another console accessing the URL using wget http://127.0.0.1:3000. It prints the following log.
current]$ bundle exec puma -b tcp://127.0.0.1:3001
Puma 2.0.1 starting...
* Min threads: 0, max threads: 16
* Environment: production
* Listening on tcp://127.0.0.1:3001
Rails Error: Unable to access log file. Please ensure that /var/app/current/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
Use Ctrl-C to stop
2015-03-16 13:19:35 +0000: HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
2015-03-16 13:19:35 +0000: ENV: {"rack.version"=>[1, 1], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "CONTENT_TYPE"=>"text/plain", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"2.0.1", "GATEWAY_INTERFACE"=>"CGI/1.2"}
So, is it compulsory to use SSL? Because I think by default, it is not enabled.
I had this issue after uploading my rails app, I found this line (auto generated) on secrets.yml (config > secrets.yml) :secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
so you have to add it as an environment variable to your environment.
In the environment dashboard go to Configuration > Software > Environment properties and add a new variable with name SECRET_KEY_BASE.
You can set any value but make sure it is a safe key.
This resolved the issue for me, I hope it helps.
I could not fix this problem. Also we supposed to use EC2 free instance only instead of BeanStalk.
We have now moved to Free EC2 instance with RDS and deployed the rails application using Capistrano with Nginx + Unicorn. Though it was not easy[1][2] but finally we got it working.
I am developing a website on RoR. Whenever I run passenger start -a 0.0.0.0 -p 3000 -d -e production command on terminal, found an error
* ERROR *
Could not start Passenger Nginx core:
nginx: [alert] could not open error log file: open()
"/tmp/passenger-standalone.1rnha9m/logs/error.log" failed (2: No such file or
directory)
2013/09/16 07:52:21 [emerg] 12190#0: getgrnam("nogroup") failed
Stopping web server... done
Please any one could guide me ?
Thanks
Actually, the could not open log file is a red herring, which has been fixed last week. The real problem is this line here:
07:52:21 [emerg] 12190#0: getgrnam("nogroup")
It means that you're starting Passenger Standalone as a user whose group is nogroup (you're probably using the nobody user), but the nogroup group does not exist in the group database. Your group database is probably broken. Please fix this first.
I am a newbie in both Rails and Apache stuff. I followed tutorials to create new rails app, and tried to deploy it using Passenger.
I generated a scaffold, created+migrated database and, and it is already working on localhost:3000.
I installed apache2 and passenger, enabled mod passenger, and I can see the usual "Welcome aboard/You’re riding Ruby on Rails!" page on localhost:80 also. But I can't reach the localhost/posts page, while I can reach localhost:3000/posts. (I see "500 Internal Server Error" page, not one of the 404/422/500 pages in the public folder). I also don't see the rails image on the index page (assets/rails.png) on port #80 -everything is OK on port #3000.
I added RackEnv developer and RailsEnv developer to the virtual host file. Apache gives no error output on screen when I restart it -It reasonably gives error when I say a2dismod passenger: "Invalid command 'RackEnv'". So I assume passenger is working.
I believe somehow apache is not reading the folders except for the public folder, I tried playing around with the permissions and ownerships with no success.
Anybody has a clue?
Thanks
EDIT: I did
rake db:create RAILS_ENV=production
rake db:migrate:reset RAILS_ENV=production
and the deleted the RackEnv/RailsEnv lines from the vhost file, and restarted apache. Now I see public/500.html on localhost/posts. it is still working on localhost:3000/posts
Logs: rails log file contains only
Migrating to CreateDenemes (20120316021657)
apache error log
[Thu Mar 15 22:22:03 2012] [notice] Digest: generating secret for digest authentication ...
[Thu Mar 15 22:22:03 2012] [notice] Digest: done
[Thu Mar 15 22:22:04 2012] [notice] Apache/2.2.20 (Ubuntu) DAV/2 Phusion_Passenger/3.0.11 mod_ssl/2.2.20 OpenSSL/1.0.0e configured -- resuming normal operation
s
and other_vhosts...log is empty
V host file:
VirtualHost *:80
ServerName sencer
DocumentRoot /home/sselcuk/sencer/public
Directory /home/sselcuk/sencer/public
AllowOverride all
Options -MultiViews
/Directory
/VirtualHost
I need your log files, both Rails and apache log.
Rails log file: see: RAILS_ROOT/log/production.log
apache log file: see /var/log/apache2 ( in ubuntu)
once getting that information, we can debug for you.
I'm getting the following error using Passenger. This seems to only be a problem when using 2.3.11. How can I fix this?
*** Passenger ERROR (ext/common/ApplicationPool/../SpawnManager.h:220):
Could not start the spawn server: /Users/oprogfrogo/.rvm/bin/ruby-1.8.7-p334#2311: Permission denied (13)
[ pid=565 thr=0x7fff70bedcc0 file=ext/apache2/Hooks.cpp:864 time=2011-06-24 08:19:03.845 ]: Unexpected error in mod_passenger: Cannot spawn application '/Users/oprogfrogo/Documents/eclipse_workspace/contracts': Could not write 'spawn_application' command to the spawn server: Broken pipe (32)
Backtrace:
in 'virtual Passenger::SessionPtr Passenger::ApplicationPool::Client::get(const Passenger::PoolOptions&)' (Client.h:750)
in 'Passenger::SessionPtr Hooks::getSession(const Passenger::PoolOptions&)' (Hooks.cpp:297)
in 'int Hooks::handleRequest(request_rec*)' (Hooks.cpp:566)
Permission denied. I would look into two places
Check the permissions on the application directory.
Check the path in the apache config file, eg should be to the public directory of the app.
Try Again
Seems the problem is with rvm. Are you using a different ruby library for this 2.3.11 app?
References
3 Good suggestions at:
http://www.modrails.com/documentation/Users%20guide%20Apache.html#_the_apache_error_log_says_that_the_spawn_manager_script_does_not_exist_or_that_it_does_not_have_permission_to_execute_it
natedavisolds, looks like it was the ruby library after all. I changed a config in my httpd.conf. It appears I was referencing the wrong location of ruby:
Before:
PassengerRuby /Users/oprogfrogo/.rvm/bin/ruby-1.8.7-p334#2311
After:
PassengerRuby /Users/oprogfrogo/.rvm/wrappers/ruby-1.8.7-p334#2311/ruby
natedavisolds & eveevans, thank you for taking the time to reply back to me quickly.
I was facing same issue when for first time I was trying to deploy an application on EC2 using passenger and nginx with rvm. My mistake was I installed passenger and nginx using sudo, so there was issue regarding permissions. I removed that installation and did rvmsudo passenger-install-nginx-module
You can refer to similar issue here.
Initially my nginx.conf file was at /etc/nginx/nginx.conf , after installation using rvmsudo it was at /opt/nginx/conf/nginx.conf
I hope this will be useful for someone.