setup ROR application using puma nginx and capistrano - ruby-on-rails

I'm trying to deploy ruby on rails application to the Amazon EC2 instance, using puma as an application server, nginx server and capistrano for deployments. Currently I'm stuck with the error message:
nginx logs are not showing any error,
puma logs are also not showing what's the error
I have verified that puma server is started and running, using the following command:
ubuntu#ip-nnnnn:~$ ps aux | grep puma
deployer 89555 0.0 1.5 652040 248180 ? Sl 21:48 0:00 puma 3.12.1 (unix://nnnn/nnn/current/tmp/sockets/puma.sock) [20211130214658]
deployer 89561 0.0 1.5 854804 259336 ? Sl 21:48 0:00 puma: cluster worker 0: 89555 [20211130214658]
deployer 89566 0.0 1.5 787216 247824 ? Sl 21:48 0:00 puma: cluster worker 1: 89555 [20211130214658]
ubuntu 89845 0.0 0.0 8168 740 pts/0 S+ 22:23 0:00 grep --color=auto puma
capistrano deploys without any error, all tasks are completed fine, the puma server is restarted fine during the capistrano deployment.
application log has no recent data, it looks like it doesn't reach to that point, it breaks before that.

In my particular case it was due to the stopped REDIS service. The application was configured to utilize REDIS for caching, however REDIS service wasn't running. This wasn't reflected in the logs for some reason and I spent a good amount of time figuring out what was wrong.

Related

Rails production with puma and nginx puma.sock missing

I'm setting up my rails production server on digital ocean with puma and nginx.
Following tutotials I have entered this in my /etc/nginx/sites-available/default
server unix:/home/deploy/appname/shared/sockets/puma.sock fail_timeout=0;
But on the server the folder home/deploy/appname/shared/sockets/ is empty.
I double checked the tutorials and none of them mentions creating such file.
If I run ps aux | grep pumaI get
root 2076 0.0 0.3 52992 3544 pts/0 T 05:51 0:00 sudo
nano require capistrano/puma root 2077 0.0 0.3 23872 3888
pts/0 T 05:51 0:00 nano require capistrano/puma rails 2407
0.0 0.0 14484 1012 pts/0 S+ 06:38 0:00 grep puma
which it doesn't really makes sense to me as I'm not using capistrano.
My question is. How is puma.sock created? During puma installation? What step have I missed if that directory is empty?
Without capistrano you need to start puma with -b option to create sock file:
puma -b unix:///__abs_path_to_your_app__/puma.sock
and in /etc/nginx/sites-available/default you need to change path to .sock file:
server unix:///__abs_path_to_your_app__/puma.sock fail_timeout=0;

can't open Puma server on port 3000 and can't find any processes to kill

I am running Puma on Rails 4.2.1 application.
When I run the following command to start the server:
rails s
I get the following error:
puma-3.4.0/lib/puma/binder.rb:255:in `initialize': Address already in use - bind(2) for "localhost" port 3000 (Errno::EADDRINUSE)
When I look for the process that is running to kill it:
ps aux | grep ruby
I get the following:
mitchellgould 52496 0.0 0.0 2432772 648 s000 S+ 3:34PM 0:00.01 grep ruby
When I run:
sudo kill -9 52496
I get:
kill: 52496: No such process
I can start the server in another port but I would like to remove this issue and understand what is happening. Any help appreciated.
ps aux | grep puma
or
ps aux | grep rails
then copy its pid and kill the process:
kill -9 PUMAS_PID
and run the server again
chell.
Try to check port 3000, maybe this is not ruby.
lsof -i tcp:3000
Fast solution:
You can restart your OS, all ports will be reset...
Delete pid with server (your_project/tmp/pids/server.pid)
Puma
Check your config for Puma in your project and how you start puma server.
Puma start with Rails

docker on upstart on scaleway

I have docker container based on ubuntu 12.04 and wish start it on scaleway This instantApp run on ubuntu 15.04 with systemd. For my container I need upstart. I turn on upstart by this recommendation:
Install the upstart-sysv package, which will remove ubuntu-standard and systemd-sysv (but should not remove anything else -- if it does, yell!), and run sudo update-initramfs -u. After that, grub's "Advanced options" menu will have a corresponding "Ubuntu, with Linux ... (systemd)" entry where you can do an one-time boot with systemd.
Now my server running with upstart:
# ps aux|grep upstart
root 1447 0.0 0.0 2632 1744 ? S 13:44 0:00 upstart-udev-bridge --daemon
root 1598 0.0 0.0 2044 176 ? S 13:44 0:00 upstart-file-bridge --daemon
root 2571 0.0 0.0 2032 1128 ? S 13:44 0:00 upstart-socket-bridge --daemon
root 32408 0.0 0.0 3156 1472 pts/4 S+ 14:27 0:00 grep --color=auto upstart
but docker not running:
# service docker status
* Docker is managed via upstart, try using service docker status
# service docker start
* Docker is managed via upstart, try using service docker start
How I can start docker as daemon?
See answer for this Ask Ubuntu question - it's a workaround to get things running again until the Kernel bug is address: https://askubuntu.com/questions/683462/docker-is-managed-via-upstart-try-using-service-docker

passenger + nginx fails when I disconnect from terminal

I use Ubuntu 12.04 LTS, rvm, passenger and nginx installed by passenger.
I connect to my server with Putty, start nginx via init.d/nginx and my Rails application works well.
But when I disconnect from terminal, I see standard application errors (Something went wrong, etc.).
nginx error log output:
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- rubygems (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:gem_prelude>:167:in `load_full_rubygems_library'
from <internal:gem_prelude>:217:in `try_activate'
from <internal:lib/rubygems/custom_require>:32:in `rescue in require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /var/lib/passenger-standalone/3.0.18-x86_64-ruby1.9.3-linux-gcc4.6.3-1002/support/helper-scripts/passenger-spawn-server:75:in `<main>'
*** Passenger ERROR (ext/common/ApplicationPool/../SpawnManager.h:220):
Could not start the spawn server: /home/torteg/.rvm/wrappers/ruby-1.9.2-p320/ruby: No such file or directory (2)
*** Passenger ERROR (ext/common/ApplicationPool/../SpawnManager.h:220):
Could not start the spawn server: /home/torteg/.rvm/wrappers/ruby-1.9.2-p320/ruby: No such file or directory (2)
ps aux output:
root 5066 0.0 0.0 220928 1936 ? Ssl 15:46 0:00 PassengerWatchdog
root 5069 0.0 0.0 1872956 2340 ? Sl 15:46 0:00 PassengerHelperAgent
root 5071 0.5 0.2 114348 10172 ? Sl 15:46 0:00 Passenger spawn server
nobody 5074 0.0 0.1 169324 4688 ? Sl 15:46 0:00 PassengerLoggingAgent
root 5105 0.0 0.0 39472 1028 ? Ss 15:46 0:00 nginx: master process /opt/nginx/sbin/nginx
torteg 5106 0.0 0.0 39892 2276 ? S 15:46 0:00 nginx: worker process
torteg 5116 13.2 1.5 225720 62432 ? Sl 15:46 0:03 Passenger ApplicationSpawner: /webapps/ngt-storage
torteg 5132 2.4 1.5 230940 64520 ? Sl 15:46 0:00 Rack: /webapps/ngt-storage
root 5141 0.1 0.1 160656 7272 ? Ss 15:47 0:00 sshd: torteg [priv]
torteg 5145 0.0 0.0 164168 1820 ? S 15:47 0:00 sshd: torteg [priv]
torteg 5291 0.0 0.0 160656 2656 ? S 15:47 0:00 sshd: torteg#pts/3
So when you ssh into your production server, somewhere else in the world (or in the cloud) and you visit mydomain.com it works. As soon as you log out of that ssh connection, nginx and passenger stop working? How are these two independent events tied to each other?
What service are you using to host this app?
Possible answer (will clean this up when you get answers to us)
I see you are using rvm too... unless the rvm path isn't set in your deploy user (just thinking out loud)
Created new user deploy with default bash shell. Installed rvm for this user. Then I set user and passenger_user to deploy in nginx.conf. Cleaned precompiled assets.. Works well!

How do I stop the phusion passenger spawn server from restarting?

I have Phusion Passenger running my Ruby on Rails application on my local machine, but I'd like to be able to kill the process entirely and run a different (non-Apache) service on the same port. Unfortunately, when I kill the passenger spawn server and the httpd processes, the spawn-server restarts:
15:30:37 /usr/bin $ ps ax | grep passenger
64659 ?? S 0:00.00 /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.8/ext/apache2/ApplicationPoolServerExecutable 0 /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.8/bin/passenger-spawn-server /usr/local/bin/ruby /tmp/passenger.64642
15:34:43 /usr/bin $ sudo kill 64659
15:34:46 /usr/bin $ sudo kill 64642
15:34:52 /usr/bin $ ps ax | grep passenger
64698 ?? S 0:00.00 /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.8/ext/apache2/ApplicationPoolServerExecutable 0 /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.8/bin/passenger-spawn-server /usr/local/bin/ruby /tmp/passenger.64681
How do I get phusion to stay dead (without rebooting the box)?
In your project directory, check out your "temp/pids" folder. There you will find that phusion passenger creates file like passenger.3000.pid, if you are running it say, on port 3000.
Now to stop this serevr on port 3000(Or any other port) just run the following command.
passenger stop --pid-file tmp/pids/passenger.3000.pid
Hm. This worked:
sudo apachectl stop

Resources