Open aseques opened 3 years ago
I face the same issue, with a KafkaConsumer.poll and it the process gets restarted due to a KeyboardInterrupt. This is also an ecosystem process, with 28 different python processes listening to kafka topics. And it only happens when running with PM2. There is no indication of what's the origin of the KeyboardInterrupt signal
I face the same issue, with a KafkaConsumer.poll
same here - pm2 causing keyboard interrupts on all python scripts
Are you running the app directly by PM2 or using systenctl? I was running with systemctl, and the service definition was pointing to a .pid file which wasn't being created, so systemctl restarted the service assuming it crashed. Check if setting the service pid to $HOME/.pm2/pid/app-pm_id.pid (as defined on https://pm2.keymetrics.io/docs/usage/application-declaration/)
@hbazan-pp I am running pm2 directly, the problem is that this only happens with the wachdog script, for some other stuff I'm using there are no issues using an ecosystem file (in the same environment)
Did this ever get fixed? I just started to use PM2 and the keyboard interrupt problem is a big headache for me. I am not using watchdog.
A few hours later......
I have an MQTT listener which should run for ever. Until I fixed the PM2 command it ran for a few seconds only with a PM2 log message about a Python KeyboardInterrupt.
After a lot of faffing about and trying "monit" I found a solution to my problem and, maybe, others too.
I created a shell script called "run_temps.sh" to run my python program something like this:
# run the workshop tasmota temperature collection application.
python3 '/home/user1/Applications/Python_Apps/workshop_temps/tasmota_to_influxdb_v1.py'
echo `date` ': Application Ran' > /home/user1/Applications/Python_Apps/workshop_temps/it-worked.txt
The python3 is to ensure that Python three is run. I had strange Python syntax problems until I did. I never got to the bottom of that problem but this method works every time. It was almost like PM2 was using Python7 - which is still on my PC for some legacy code.
Make the script executable in the usual way and test it using "./run_temps.sh"
Whilst you are in the same directory as the shell script add to PM2 using this command:
pm2 start run_temps.sh </dev/null
Redirecting the input completely stopped the problem. The task can still be started, restarted and stopped as normal. I have seen no side effects at all.
After many hours the log is empty and the application is working. ;-)
still not resolved....
What's going wrong?
I would like to use ecosystem.config.yaml to launch a python process instead of the command line (that's what I'm currently doing), I am using watchdog (a tool to monitor directorys an launch commands) I get a stacktrace from python telling that there was a keyboard interrupt only when starting from ecosystem file.
But I can launch the process normally from command line.
How could we reproduce this issue?
Command line (it works)
watchmedo shell-command --command='pwd' /tmp/
Ecosystem (KeyboardInterrupt)
Supporting information