Error: Could not start Passenger Nginx core - ruby-on-rails

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.

Related

Trying to hunt down location of a string, associated with a postgres installation (connection option: "port")

I'm on a new-ish macbook: MacOs Big Sur.
I installed a local development environment via https://rails.new/.
For my day-job, we run everything in Docker, but I'm also doing ruby/rails develpment within that docker context.
I've had a beast of a time trying to connect to a local working postgres service.
Any time I try to run migrations, or connect via the terminal with psql, I get a similar error message, that makes me wonder if I fat-fingered a value into a text file somewhere, and don't know where:
rails db:migrate
rails aborted!
ActiveRecord::ConnectionNotEstablished: invalid integer value "5432export" for connection option "port"
Caused by:
PG::ConnectionBad: invalid integer value "5432export" for connection option "port"
Or when I run psql:
$ psql
psql: error: invalid integer value "5432export" for connection option "port
This happens even when I do rails new, so I think I messed up with something in a plist file or postgres config somewhere. It's not happening on my other laptop. This string doesn't exist in the results of rails new, so I assume it's inside of a postgres config file somewhere.
$ which psql
/usr/local/bin/psql
$ brew list postgres
/usr/local/Cellar/postgresql/14.3/bin/clusterdb
/usr/local/Cellar/postgresql/14.3/bin/createdb
/usr/local/Cellar/postgresql/14.3/bin/createuser
/usr/local/Cellar/postgresql/14.3/bin/dropdb
/usr/local/Cellar/postgresql/14.3/bin/dropuser
/usr/local/Cellar/postgresql/14.3/bin/ecpg
/usr/local/Cellar/postgresql/14.3/bin/initdb
/usr/local/Cellar/postgresql/14.3/bin/oid2name
/usr/local/Cellar/postgresql/14.3/bin/pg_amcheck
/usr/local/Cellar/postgresql/14.3/bin/pg_archivecleanup
/usr/local/Cellar/postgresql/14.3/bin/pg_basebackup
/usr/local/Cellar/postgresql/14.3/bin/pg_checksums
/usr/local/Cellar/postgresql/14.3/bin/pg_config
/usr/local/Cellar/postgresql/14.3/bin/pg_controldata
/usr/local/Cellar/postgresql/14.3/bin/pg_ctl
/usr/local/Cellar/postgresql/14.3/bin/pg_dump
/usr/local/Cellar/postgresql/14.3/bin/pg_dumpall
/usr/local/Cellar/postgresql/14.3/bin/pg_isready
/usr/local/Cellar/postgresql/14.3/bin/pg_receivewal
/usr/local/Cellar/postgresql/14.3/bin/pg_recvlogical
/usr/local/Cellar/postgresql/14.3/bin/pg_resetwal
/usr/local/Cellar/postgresql/14.3/bin/pg_restore
/usr/local/Cellar/postgresql/14.3/bin/pg_rewind
/usr/local/Cellar/postgresql/14.3/bin/pg_test_fsync
/usr/local/Cellar/postgresql/14.3/bin/pg_test_timing
/usr/local/Cellar/postgresql/14.3/bin/pg_upgrade
/usr/local/Cellar/postgresql/14.3/bin/pg_verifybackup
/usr/local/Cellar/postgresql/14.3/bin/pg_waldump
/usr/local/Cellar/postgresql/14.3/bin/pgbench
/usr/local/Cellar/postgresql/14.3/bin/postgres
/usr/local/Cellar/postgresql/14.3/bin/postmaster
/usr/local/Cellar/postgresql/14.3/bin/psql
/usr/local/Cellar/postgresql/14.3/bin/reindexdb
/usr/local/Cellar/postgresql/14.3/bin/vacuumdb
/usr/local/Cellar/postgresql/14.3/bin/vacuumlo
/usr/local/Cellar/postgresql/14.3/homebrew.mxcl.postgresql.plist
/usr/local/Cellar/postgresql/14.3/homebrew.postgresql.service
/usr/local/Cellar/postgresql/14.3/include/libpq/libpq-fs.h
/usr/local/Cellar/postgresql/14.3/include/postgresql/ (827 files)
/usr/local/Cellar/postgresql/14.3/include/ (23 files)
/usr/local/Cellar/postgresql/14.3/lib/libecpg.6.14.dylib
/usr/local/Cellar/postgresql/14.3/lib/libecpg_compat.3.14.dylib
/usr/local/Cellar/postgresql/14.3/lib/libpgtypes.3.14.dylib
/usr/local/Cellar/postgresql/14.3/lib/libpq.5.14.dylib
/usr/local/Cellar/postgresql/14.3/lib/pkgconfig/ (4 files)
/usr/local/Cellar/postgresql/14.3/lib/postgresql/ (91 files)
/usr/local/Cellar/postgresql/14.3/lib/ (17 other files)
/usr/local/Cellar/postgresql/14.3/share/doc/ (1143 files)
/usr/local/Cellar/postgresql/14.3/share/man/ (294 files)
/usr/local/Cellar/postgresql/14.3/share/postgresql/ (860 files)
I've reinstalled postgres via brew
and postgres seems to be running:
$ brew services
Name Status User File
postgresql none
postgresql#13 started username ~/Library/LaunchAgents/homebrew.mxcl.postgresql#13.plist
When I switch the running service, I get the same problem:
$ brew services stop postgresql#13
Stopping `postgresql#13`... (might take a while)
==> Successfully stopped `postgresql#13` (label: homebrew.mxcl.postgresql#13)
$ brew services start postgresql
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
$ psql
psql: error: invalid integer value "5432export" for connection option "port"
I am starting to try to run find commands, in my terminal, looking through the bin directory for the string 5432export but have not found it, and really don't know much about what lives inside of bin/psql, or even even if I'm looking in the correct general location.
I've tried different versions of ruby and rails, as well. Just can't get away from this error on this laptop!
Update:
When I run psql -p 5432, I get:
$ psql -p 5432
psql: error: connection to server at "127.0.0.1", port 5432 failed: FATAL: role "postgres" does not exist
And:
$ psql -p 5432 -U postgres
psql: error: connection to server at "127.0.0.1", port 5432 failed: FATAL: role "postgres" does not exist
Update 2:
Solved below! It was an environment variable issue, phew, thank you so much, this was driving me bonkers:
$ env | grep PG
PGHOST=127.0.0.1
PGPORT=5432export
PGUSER=postgres

Passenger standalone can't start server after enabling SSL on Rails project

I have a Rails project up on an EC2 server at AWS. To deploy it, I followed this Passenger tutorial to the letter:
https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/standalone/oss/deploy_app_main.html
Everything worked fine. Then I followed this Passenger tutorial to get SSL working:
https://www.phusionpassenger.com/library/deploy/standalone/prod_ssl.html
My Passengerfile and nginx conf file look the same as the ones in the link (with the paths replaced to point to the correct files). But now, best I can gather, the nginx server isn't starting when I use the command sudo bundle exec passenger start.
I found this on the nginx log:
May 29 18:46:20 ip-172-31-38-233 systemd[18230]: nginx.service: Failed to execute command: No such file or directory
May 29 18:46:20 ip-172-31-38-233 systemd[18230]: nginx.service: Failed at step EXEC spawning /usr/sbin/nginx: No such file or directory
Which doesn't make sense to me as nginx was working fine before the SSL certificates. Note I'm using Passenger standalone, so I'm not managing nginx myself.

Rails app not reflecting recent changes at all

I have a rails(Rails 3.2.12, ruby 1.9.3p547) app running on AWS ubuntu cloud server, with nginx as app server and unicorn as reverse proxy server.
I have made few changes in the view file but those changes are not reflecting on browser. Code is currently live ("env=production")
I tried
sudo service my_app restart
[sudo] password for me:
Shutting down my_app: Starting my_app: Already running
[ OK ]
$ sudo service nginx restart
Stopping nginx: [ OK ]
Starting nginx: [ OK ]
$
but still got no help its still rendering the previous one. I tried commenting the whole controller file for the same view but still the app is not showing any error. I have confirmed that the app is running from the same folder in which I am making changes
I got stuck at this point please help. Thanks in Advance
Got the issue resolved with the help of the comments which gave me the idea.
located the .pid file in tmp/pids/unicorn.pid which was having the current process id
$ kill -QUIT 5454 #process id
and then again started the unicorn service and nginx service, and changes started reflecting

502 bad gateway nginx + puma + rails 3.2 on Elastic Beanstalk

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&#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.

Passenger Unexpected error in mod_passenger: Cannot connect to Unix socket

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 ]

Resources