After I have started sshd service in my cygiwn(1.7.33 64bit on win8.1 64bit), there has 3 processes( in red box) and two of them have dynamic pids(yellow box). If I use kill command for the process in the yellow box, it responce no such process, but if you use the ps command again, you will see they are still there, but with a different pids.
http://i.stack.imgur.com/hAU4e.png
http://i.stack.imgur.com/Q6all.png
Related
I started a node script inside WebStorm once. It is a VueJS application. It is running on localhost:5000. When I open it inside chrome, I can see that it first is not responding, and then it suddenly loads. That tells me that the process is always restarting and inside a loop.
When I run ps aux | grep node , I can see the process quickly changing the process ID. That confirms my observation. If I try to kill the process it tells me that there is no process with that ID because it restarted that quickly. The process also is starting when reboot the computer. I also completely uninstalled NodeJS from my computer, but strangely it is starting anyways. I'm on macOS and I don't know what I could try anymore.
ps aux | grep node output:
2959 0,0 0,0 4268464 740 s000 S+ 3:47pm 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox node
I don't have enough reputation to leave a comment on your question, so I'm writing here.
It seems like you're application somehow registered in the service which happened to me as well. Mine was CentOS7.
You can check if it's added into service and run automatically whenever the machine is on. The command is Linux ones, so I'm not sure whether it's gonna work on MacOS as well.
//check list
chkconfig --list
//turn off the automatic start
chkconfig [your application name] off
If changing service config by using above commands did not work, you can search for the Mac Service Script. I think service shell script are different. Again, my case was on CentOS7.
Hope it helps.
I'm currently running a python script as a systemd service. Is there any way to "switch" into the service and take control of the script? The script has a menu but runs calculations in the background in another thread. Most likely not, so is there a way to run a python script 24/7, start on boot, restart on crash etc (just like systemd service) but be able to take control of it after I connect to the server via SSH, so I can manipulate the app?
One solution you could try would be to edit the systemd configuration to launch the process in screen or tmux, then attach that when logging in via SSH.
For instance, in the systemd unit, you might have:
[Service]
Type=single
ExecStart=tmux new "command"
Using Type=single will treat the tmux command as the main process, which would be killed if you stop it with systemctl stop systemprocess
The ExecStart=tmux new "command" creates a new tmux session with the command inside of it.
You can then attach to it using tmux attach as the same user the systemd unit is running as (I believe this is root by default).
I have an ubuntu server running with 2 node websites on it and I keep closing the terminals that start the app so I cannot shut the app down to make changes, I end up restarting the server.
How can I see what node instances are running and then stop them, or how do I stop a node instance through programming and I'll just make a button that kills the node instance. Either way...
If you dont want to use PM2 or systemd you can get the list of all the node.js instances running using
ps -aux | grep node
once you have the list of all nodejs processes you can kill any process using kill command
kill "Process ID goes here"
Use a process manager. PM2 is the most widely recommended.
npm install pm2#latest -g
then
pm2 start app.js
Alternatively you can use something like screen to have multiple terminal sessions running in one window
I want to auto restart my application "Fiware IoT Agent" if it stopped, the problem is that it depends of Mongo Db Data Base and the Mosquitto broker. My OS is centOS 7
Here is the commands that I use to launch my three application in the following order:
*Mongo:
/usr/local/iot/mongodb-linux-x86_64-3.0.5/bin/mongod --dbpath /usr/local/iot/mongodb-linux-x86_64-3.0.5/data/db$
*Mosquitto broker
/usr/sbin/mosquitto -c /etc/iot/mosquitto.conf &
pid=$!
echo $pid > /var/run/iot/mosquitto.pid
Iot Agent:
than I start my application using this command
export LD_LIBRARY_PATH=/usr/local/iot/lib
/usr/local/iot/bin/iotagent -i 192.168.1.11 -p 80 -v DEBUG -d /usr/local/iot/lib -c /etc/iot/config.json
how can I start my application if it stopped known that it depends of the other two application? If for example Mongo DB stopped, I must be able to restart it and then to restart my application.
CentOS 7 uses systemd. You can create systemd service for each of your applications and specify dependencies between them. And specify "Restart=always" for service which need to be auto restarted.
You can create your own watch dog code. When you start your application get the pid of the process and the pid of mongo DB.
Every couple of second like 10 seconds check that the pid of both process still exist, or you can also make the programs touch a file every couple of seconds as well then check the file modification time to see if the programs are still alive.
If the program hasn't touched the file or if you go jus the pid route and the pid doesn't exist. Then the program has died.
Restart the program and get the new pid and go about again in a forever while loop.
I got a live server running nodejs chat app. I connect to server using terminal on mac. I start the server by typing server.js.
the problem is, my terminal always hung after one hour running, and there are no error outputs. when it hangs, I press ctrl+c I got the message [process completed].
note: My terminal runs node apps locally without any problems.
And my current chat app run well when I initiate it with WinSCP in windows platform.
Try launching your node process on the remote server using a tool like nohup.
bash$ nohup /path/to/node server.js > out.txt 2> err.txt &
[1] 53032
# Now you can logout of the remote server without
# killing the "node" process and chat server.
[Edit]
Note that the number printed by "nohup" (e.g. 53032) is the id of detached process, so if you need to terminate it you can do something like "kill -9 53032". If you forgot to record that number then you'll have to find it by using a program such as "ps"; for example, you can run "ps auxwww | grep node" (the flags will vary depending on your system) and you'll see output similar to this:
maerics 81694 0.6 0.5 2543604 21216 s000 S+ 10:34AM 0:09.45 /Users/maerics/opt/node/node server.js
In this example, on my system, the number in the second column is the process id.