Ruby-on-rails 服务器已经在运行。检查.../tmp/pids/server.pid。退出 - 导轨
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24627701/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
A server is already running. Check …/tmp/pids/server.pid. Exiting - rails
提问by ben
..$ rails s
=> Booting WEBrick
=> Rails 4.0.4 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
A server is already running. Check /home/..name/rprojects/railsapp/tmp/pids/server.pid.
Exiting
what is the easiest way to solve this for a rails beginner?
对于 Rails 初学者来说,解决这个问题的最简单方法是什么?
回答by ben
You can delete the server.pidfile.
您可以删除该server.pid文件。
rm /your_project_path/tmp/pids/server.pid
Else:
别的:
try in OSX:
在 OSX 中尝试:
sudo lsof -iTCP -sTCP:LISTEN -P | grep :3000
or in linux:
或在 linux 中:
ps -aef | grep rails
ps -aef | 铁轨
or
或者
lsof -wni tcp:3000
kill the process using
使用杀死进程
kill -9 PID (eg,2786)
回答by Karan Purohit
Short and Crisp single line command, that will take care of it.
简短而清晰的单行命令,它将处理它。
kill -9 $(lsof -i tcp:3000 -t)
回答by Lane
If you are using docker-compose, and in docker-compose.yml have:
volumes:
- .:/myapp
That means you local workspace is mapped to the container's /myapp folder.
如果您正在使用 docker-compose,并且在 docker-compose.yml 中有:
volumes:
- .:/myapp
这意味着您的本地工作区已映射到容器的 /myapp 文件夹。
Anything in /myapp will not be deleted for the volumes define.
不会为卷定义删除 /myapp 中的任何内容。
You can delete ./tmp/pids/server.pidin you local machine. Then the container's /myapp will not have this file.
您可以./tmp/pids/server.pid在本地机器中删除。那么容器的 /myapp 就没有这个文件了。
回答by muichkine
server.pidonly contains the process ID of the running server.
server.pid只包含正在运行的服务器的进程 ID。
If you do:
如果你这样做:
more /your_project_path/tmp/pids/server.pid
you will get a number (say 6745) which you can use to stop the previous server with the command kill:
你会得到一个数字(比如 6745),你可以用它来用 kill 命令停止以前的服务器:
kill -9 6745
and then you can remove the file with the rmcommand
然后你可以使用rm命令删除文件
rm /your_project_path/tmp/pids/server.pid
回答by Lorenzo Sinisi
Simple:
简单的:
go in the root folder of the project when this happens and run:
发生这种情况时进入项目的根文件夹并运行:
gem install shutup
shutup
This will find the process currently running, kill it and clean up the pid file
这将找到当前正在运行的进程,杀死它并清理 pid 文件
NOTE: if you are using rvm install the gem globally
注意:如果您使用 rvm,请全局安装 gem
rvm @global do gem install shutup
回答by webster
Issue can be solved using:
可以使用以下方法解决问题:
kill -9 $(more /home/..name/rprojects/railsapp/tmp/pids/server.pid)
回答by DragonKnight
It happens sometimes because you turn off the server by force, for example turning off the OS/machine manually so that the server does not have enough time to log to server.pid.
有时会发生这种情况,因为您强行关闭服务器,例如手动关闭操作系统/机器,以便服务器没有足够的时间登录 server.pid。
One easy way is to manually go to tmp/pids/(the directory that is shown in your console.) and remove server.pidfile. Then, when you start the server again, rails serveror rails s,it creates a new server.pid and you can continue development.
一种简单的方法是手动转到tmp/pids/(控制台中显示的目录。)并删除server.pid文件。然后,当您再次启动服务器时,rails server或者rails s,它会创建一个新的 server.pid,您可以继续开发。
回答by Alexander Sidikov Pfeif
回答by Daniel Okwufulueze
Open the path/to/your/rails/project/tmp/pids/server.pidfile.
打开path/to/your/rails/project/tmp/pids/server.pid文件。
Copy the number you find therein.
复制您在其中找到的号码。
Run kill -9 [PID]
跑 kill -9 [PID]
Where [PID]is the number you copied from the server.pidfile.
[PID]您从server.pid文件中复制的号码在哪里。
This will kill the running server process and you can start your server again without any trouble.
这将终止正在运行的服务器进程,您可以毫无困难地再次启动服务器。
回答by Jimmy MG Lim
For added information, under the context of running the application in docker.
有关附加信息,请在 docker 中运行应用程序的上下文中。
In docker-compose.yml file, under the application container itself, you can use one of the following:
在 docker-compose.yml 文件中,在应用程序容器本身下,您可以使用以下其中一种:
command: ["rm /your-app-path/tmp/pids/server.pid && bundle exec bin/rails s -p 3000 -b '0.0.0.0'"]
or
或者
command: ["rm /your-app-path/tmp/pids/server.pid; foreman start"]
Note the use of either ;or &&, that &&will send an exit signal if rmfails to find the file, forcing your container to prematurely stop. Using ;will continue to execute.
请注意使用;or &&,&&如果rm找不到文件,它将发送退出信号,迫使您的容器过早停止。using;将继续执行。
Why is this caused in the first place?The rationale is that if the server (puma/thin/whatever) does not cleanly exit, it will leave a pid in the host machine causing an exit error.
为什么首先会造成这种情况?基本原理是,如果服务器(puma/thin/whatever)没有干净地退出,它将在主机中留下一个 pid,导致退出错误。
For portability rather than manually deleting the file on the host system, it's better to check if the file exists within scripted or compose file itself.
为了可移植性而不是手动删除主机系统上的文件,最好检查该文件是否存在于脚本或组合文件本身中。


