deployed to heroku, can't see project in development - ruby-on-rails

I built a rails app and successfully deployed it to heroku
Now I would like to access the development version to make changes on my local machine
When I rails s I get the error:
A server is already running. Check /home/username/myApp/tmp/pids/server.pid
That file has one line that reads 2673
What can I do to start the rails server while the app is hosted on heroku?

rm /home/username/myApp/tmp/pids/server.pid
Then
rails s
If it is not working
If you want to kill rails server process on port 3000 (which is what webrick normally uses), type this in your terminal to find out the PID of the process:
$ lsof -wni tcp:3000
Then, use the number in the PID column to kill the process:
$ kill -9 PID
Then
rails s
Hope you will be able to run rails server again in your local m/c

Related

A server is already running. (Ruby on Rails)

I was practicing doing ruby on rails and I accidentally closed Visual Studio code while the terminal and rails server is running.
This is what happened after i typed rails s
PS C:\Users\Lenovo\Desktop\folder_name\project_name rails s
=> Booting Puma
=> Rails 6.1.4.1 application starting in development
=> Run `bin/rails server --help` for more startup options
A server is already running. Check C:/Users/Lenovo/Desktop/folder_name/project_name/tmp/pids/server.pid.
Exiting
Find the process id for the rails server port :
lsof -wni tcp:3000
Copy value in PID column
Kill the process (for example 14400) :
kill -9 14400
You can use this command to kill the server using port number.
sudo kill -9 $(lsof -i :3000 -t)
The user just needed to delete the server.pid file and it worked.

How to start rails server command as daemon that relaunch after reboot or crush?

I setup Nginx for listening to lockalhost:3000 than I launch rails command bundle exec rails server webrick -e production. I found that I can launch rails server as daemon simply adds the -d flag to the command, so the command becomes a bundle exec rails server -d webrick -e production. My problem is that after server reloads or app is crushed - that a dead-end, I can't found info about how should I create "rails as a daemon with auto relaunch".
webrick in production?
Please please please refrain from doing anything like that. Use puma or unicorn or any similar app server for your purpose.
And for the process monitoring part, you can use systemd, or monit for better control.
Personally, I prefer monit as it gives me crash logs and downtime alerts.

Rails - A server is already running

I have a problem when I want to start my server in my terminal I do rail s or rails server and there is an error A server is already running. Check /Users/baptiste/code/BaptisteB/my-app/tmp/pids/server.pid.
What does it mean? And why it is present?
I delete it and when I check my localhost:3000. There is nothing. I have to log off my laptop and turn on it to begin to work.
How could I stop this error? Maybe I can destroy it with a command. Thank you for your help.
Try to run below command on your terminal and you will get pid (process id)
lsof -wni tcp:3000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ruby 21309 user 11u IPv4 93186 0t0 TCP *:3000 (LISTEN)
and then kill your ruby process by using
kill -9 <PID>
start your server again by rails s
Hope it helps!
It means that you have already started a rails server. What's possibly happened is that you started a rails server and closed that terminal window without stopping the server. Open a terminal window and run
ps aux | grep rails
that should give you a list of all the processes running with rails in its name. Then you can run the command below to kill all of them or get the pid (process id) and selectively terminate them with the second command. If you're on wi
killall -9 rails
kill pid
Simple:
$ cd # in the project folder
$ gem install shutup
$ shutup
If using rvm do:
$ cd # in the project folder
$ rvm #global do gem install shutup
$ shutup

Webrick Fails to Run as Daemon, no Error Message

Running Ubuntu Server 10.04 with Rails 2.3.4 and Webrick 1.3.1; our rails app runs fine when called via script/server -e production, but trying to test it as a daemon by calling it with the -d flag produces the following output:
=> Booting WEBrick
=> Rails 2.3.4 application starting on http://0.0.0.0:3000
Nothing is produced in the logs, and other Rails applications will run detached without issue.
I assume You are running the Webrick in port 3000
>>$ sudo netstat -anp | grep 3000
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 8822/ruby
>>$ sudo kill -9 8822
I don't mean to contradict your choosing Webrick as a production server and maybe there is something I'm missing about why you are choosing Webrick, but have you considered other alternatives? I'd wager you already know all of this, but Webrick is the provided ruby server, and it is also the slowest ruby server choice.
Some of the most popular production server choices are:
Passenger
Thin
Mongrel
Unicorn
Glassfish
Passenger is likely the most popular choice for production now due to its easy configuration, speed, and features.
If there is a specific use case for Webrick that makes it better than any of the other server choices, I'd love to know.
You can add patch to enable error log here: https://github.com/rails/rails/blob/3-2-stable/activesupport/lib/active_support/core_ext/process/daemon.rb#L16
To
unless noclose
STDIN.reopen "/dev/null" # Free file descriptors and
STDOUT.reopen "/dev/null", "a" # point them somewhere sensible.
STDERR.reopen '/tmp/rails_daemon_err.log', 'a'
end
Now when you start rails server with -d, the error log will append to /tmp/rails_daemon.log.

Restarting Teambox Server

I'm running Teambox (a Ruby on Rails app) and have the server running with:
script/server -e production
Knowing absolutely nothing about Ruby on Rails I just wandered how I could restart the server to get it to update changes I've made to the config?
If you ran it with that command line it's probably running actively in the console, just CTRL+C.
If you ran it daemonize you will need to find the process and kill it.

Resources