Can't stop rails server

前端 未结 27 1961
别跟我提以往
别跟我提以往 2020-12-04 05:12

I am new to rails and I am using an ubuntu machine and the rubymine IDE. The problem is that I am unable to stop the rails server. I tried to stop the server by killing the

27条回答
  •  有刺的猬
    2020-12-04 05:20

    It is late for this question. Here is my 2 cents. I made a rake task for stopping the server when I don't have access to it. I only tested on Mac though.

    With this you can simply add it to your project then run the rake command.

    Here you go:

    Gist link: -latest version will be here. https://gist.github.com/houmanka/289184ca5d8d92de0499#file-server-rake

    Some code in here:

    # Make a file under: `project_root/lib/tasks/server.rake`
    
    # Then paste the following code
    
        namespace :server do
          desc "Stop the running server by killing the PID"
          task :kill do
            STDOUT.puts "Enter port number: "
            post_number = STDIN.gets.strip
            system "pid=$(lsof -i:#{post_number.to_i} -t); kill -TERM $pid || kill -KILL $pid"
          end
        end
    
    # Then to use it in the terminal: `rake server:kill`
    

提交回复
热议问题