What to do if rails server can't be stopped

Introduction

Sometimes the rails server couldn't start while proceeding with the Rails tutorial. The bottom line was that I thought I was quitting the rails server, but I couldn't quit it, and I couldn't start it again because it was still running. As a memorandum, I have summarized the cases where rails server could not be terminated and how to terminate it.

Operating environment

When rails server can't be stopped

  1. Look up the rails server process number with the option aux on the ps command. The process whose last COMMAND item is the Rails app name is the corresponding process.

        $ ps aux 
        USER PID   %CPU  %MEM VSZ     RSS   TTY   STAT START   TIME COMMAND
        ----
    

hoge 31701 15.0 0.2 1095324 70456 tty15 Sl 12:00 0:01 puma 4.3.4 (tcp: // localhost: 3000) [app name] ----

  1. Kill this process with the kill command.

        $ kill 31701
    
  2. The process number is also listed in the following file. View the contents with the cat command.

        $ cat tmp/pids/server.pid
        31701
    
  3. Pipe the result of ps to grep to make it easier to find the process

$ ps aux | grep app name USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND hoge 31701 15.0 0.2 1095324 70456 tty15 Sl 12:00 0:01 puma 4.3.4 (tcp: // localhost: 3000) [app name] hoge 243 0.0 0.0 14804 1188 tty25 S 14:15 0:00 grep --color = auto App name

  1. When you accidentally quit with Ctrl + Z etc., it looks like it's quit, but Rails server is still running.

        $ rails s
        => Booting Puma
        => Rails 6.0.3 application starting in development
        => Run `rails server --help` for more startup options
        Puma starting in single mode...
        * Version 4.3.4 (ruby 2.7.1-p83), codename: Mysterious Traveller
        * Min threads: 5, max threads: 5
        * Environment: development
        * Listening on tcp://127.0.0.1:3000
        * Listening on tcp://[::1]:3000
        Use Ctrl-C to stop
        ^Z
        [1]+  Stopped                 rails s
    
  2. Look up the process number and execute the kill command with option -9, as in "When you close the terminal window without Ctrl + C". The process may not end without the option.

        $ kill -9 31701
    

Reference article

Quickly drop Rails server process

that's all.

Recommended Posts

What to do if rails server can't be stopped
What to do if the Rails server can't start
What to do if you can't use the rails command
[Rails] What to do if you can't get parameters with form_with
What to do if the server tomcat dies
What to do if the rails server doesn't run out on AWS cloud9
# What to do if you accidentally do rails db: migrate: drop
What to do if the adb command cannot be executed
What to do if you can't find your API key after deploying to Rails heroku
[Rails] What to do if data is not registered in DB
What to do if the Rails page doesn't appear in Rails tutorial 1.3.2
What to do if Cloud9 is full in the Rails tutorial
[Rails] What to do if you can't get an error message with the errors method
What to do if you install Ubuntu
What to do if you get an error during rails db: reset
What to do if you can't install the plugin from the Eclipse marketplace
What to do if tomcat process remains when tomcat is stopped in eclipse
What to do if you push incorrect information
What to do if mvn archetype: generate fails
What to do if you can't bundle update and bundle install after installing Ruby 3.0.0 in the Rails tutorial
What to do if SPA URL loading cannot be detected by WebView shouldOverrideUrlLoading
What to do if ffi installation fails when launching an application in Rails
What to do if the debug gem installation fails
What to do if TextToSpeech doesn't work on Android 11
What to do if you get an "A server is already running." Error when you try to start the rails server
What to do if you accidentally create a model
What to do when rails creates a 〇〇 2.rb file
What to do if an ActionController :: UnknownFormat error occurs
What to do if password authentication fails in Docker/Postgres
What to do if the update does not take effect after deploying Rails AWS
What to do if you can't get the text of an element in Selenium
[Ruby on Rails] How to stop when Rails server cannot be stopped by Ctrl + C
How to terminate rails server
What to do if you get an error saying "Could not find a JavaScript runtime." When starting rails server
What to do when you launch an application with rails
What to do if audio is not available on discordrb
What to do if FacesMessage is set but not displayed
What to do if mysql2 gets a bundle install error
What to do if you enable UFW on Ubuntu VM on GCP and you can't connect to SSH
[Rails] What to do if you accidentally install bundle in the production environment in your local environment
What to do if you get a "302" error in your controller unit test code in Rails
What to do if you get an error in Basic authentication during Rails test code
[Ubuntu 20.04] What to do if the external monitor is not recognized
What to do if validation doesn't work with the update action
What to do if you get a "Mysql2 :: Error: Operand should contain 1 column (s)" error in Rails
[Note] What to do if bundle install in Chapter 3 of the rails tutorial is not possible
What to do if the Eclipse Maven dependency Jar is wrong
[Rails] What to do when rails s does not respond or does not stop
What to do if you get a DISPLAY error in gym.render ()
What to do after Vagrant install
What to do if you get angry with OpenSSL with pyenv install
Connect to Rails server with iPhone
[Logback] What to do if unnecessary files do not disappear during rotation
What to do if the app is not created with the latest Rails version installed when rails new
What to do when javax.batch.operations.JobStartException occurs
What to do if you forget the root password in CentOS7
What to do if you cannot roll back the migration (UnknownMigrationVersionError)
What to do if you should have installed Rails but an error occurs with rails -v (for beginners)
What to do if the image posted by refile disappears after setting a 404 error page in Rails
[Rails / Docker] What to do if access is denied by the browser (localhost: 3000) after adding a gem
What to do if changes are not reflected after automatic deployment to EC2