简体   繁体   English

如何杀死重新启动的进程? (永远)

[英]How to kill a process that restarts? (Forever)

I think I accidentally installed Foreverjs somewhere and started it.我想我不小心在某个地方安装了 Foreverjs 并启动了它。 Every time I kill this process another one takes its place每次我终止这个进程时,另一个进程就会取而代之![在此处输入图片说明] 1 ] 1

I have no idea where forever might be (or if thats actually whats causing it) because I install it locally.我不知道永远在哪里(或者这是否真的是导致它的原因),因为我在本地安装它。

Take a look at Where does npm install packages?看看npm哪里安装包? and npm folders documentationnpm 文件夹文档

Local install (default): puts stuff in ./node_modules of the current package root.本地安装(默认):将东西放在当前包根目录的 ./node_modules 中。

Global install (with -g): puts stuff in /usr/local or wherever node is installed .全局安装(使用 -g):将东西放在/usr/local安装 node 的任何地方

run which forever to get the path where its installed and uninstall it with which forever运行which forever以获取其安装路径并将其卸载

  • forever stopall
  • npm uninstall forever if its globally installed add -g如果全局安装了npm uninstall forever add -g

If it restarts itself it means there is a parent process monitoring.如果它自己重新启动,则意味着存在父进程监控。 Find the parent process and kill it first ps -o ppid= -p PID .找到父进程并先杀死它ps -o ppid= -p PID

Turns out I had run the same script on PM2 on both a root user and of my new privileged user.结果我在 PM2 上的 root 用户和我的新特权用户上运行了相同的脚本。 The root user kept restarting the process with PM2 every time i killed it and its parent.每次我杀死它及其父进程时,root 用户都会用 PM2 重新启动进程。 So I did this所以我做了这个

sudo su
pm2 status //to check pm2 processes
pm2 delete process_name //to delete the process
exit 
pm2 start "yarn start" --name process_name

Hope this helps save someone else's time希望这有助于节省别人的时间

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM