alexsilva / supervisor

Supervisor process control system for Windows
http://supervisord.org
Other
118 stars 26 forks source link

Can't stop processes #13

Closed pscholze closed 4 years ago

pscholze commented 4 years ago

Running 4.2.0 on Windows 10. When trying to stop a process, I get following error. Same problem using TERM and INT as stopsignal. Defining KILL is not accepted.

supervisor> stop phonebook
FAILED: unknown problem killing phonebook (15152):Traceback (most recent call last):
  File "C:\Program Files\Python36\lib\site-packages\supervisor\process.py", line 599, in kill
    options.kill(pid, sig)
  File "C:\Program Files\Python36\lib\site-packages\supervisor\options.py", line 1159, in kill
    self.pidhistory[pid].process.send_signal(sig)
KeyError: -15152
alexsilva commented 4 years ago

Which version of python ? I will need the settings used in superviosor.conf.

pscholze commented 4 years ago

Python 3.6.8

supervisor.conf:

[inet_http_server]    
port=*:9001       

[supervisord]
logfile=D:\build\supervisor\supervisord.log 
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
pidfile=D:\build\supervisor\supervisord.pid
nodaemon=false
minfds=1024
minprocs=200

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]

[include]
files = D:\build\supervisor\config\*.ini
alexsilva commented 4 years ago

The process settings were missing but was the option 'killasgroup' configured ?

pscholze commented 4 years ago

Yes. killasgroup is set true.

alexsilva commented 4 years ago

Update your version of the supervisor and see if the problem is resolved

python -m pip install git+https://github.com/alexsilva/supervisor.git@windows -U

pscholze commented 4 years ago

With updated version:

supervisor> stop phonebook
FAILED: unknown problem killing phonebook (13320):Traceback (most recent call last):
  File "C:\Program Files\Python36\lib\site-packages\supervisor\process.py", line 599, in kill
    options.kill(pid, sig)
  File "C:\Program Files\Python36\lib\site-packages\supervisor\options.py", line 1159, in kill
    output = self.pidhistory[abs(pid)].process.kill2(pid, sig)
  File "C:\Program Files\Python36\lib\site-packages\supervisor\helpers.py", line 48, in kill2
    return self.taskkill()
  File "C:\Program Files\Python36\lib\site-packages\supervisor\helpers.py", line 54, in taskkill
    '/F', '/T'])
  File "C:\Program Files\Python36\lib\subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "C:\Program Files\Python36\lib\subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['taskkill', '/PID', '13320', '/F', '/T']' returned non-zero exit status 255.
alexsilva commented 4 years ago

You can enter the supervisor log and the phonebook process settings ?

pscholze commented 4 years ago

Process INI:

[program:phonebook]
command=cmd.exe /c "mycommand"
stdout_logfile=D:\build\supervisor\logs\%(program_name)s.log
stdout_logfile_maxbytes=50MB
redirect_stderr=true
environment=BUILD_LOG="C:\log"
stopasgroup=true
killasgroup=true
stopsignal=TERM
stopwaitsecs=30
pscholze commented 4 years ago

supervisor.log

2020-04-17 11:28:58,734 INFO supervisord started with pid 16888
2020-04-17 11:28:59,744 INFO Spawned: 'phonebook' with pid 8772
2020-04-17 11:29:00,963 INFO success: phonebook entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2020-04-17 11:29:24,557 INFO configuration reloaded (added: [] changed: [] removed: [])
2020-04-17 11:29:36,542 CRIT unknown problem killing phonebook (8772):Traceback (most recent call last):
  File "C:\Program Files\Python36\lib\site-packages\supervisor\process.py", line 599, in kill
    options.kill(pid, sig)
  File "C:\Program Files\Python36\lib\site-packages\supervisor\options.py", line 1159, in kill
    output = self.pidhistory[abs(pid)].process.kill2(pid, sig)
  File "C:\Program Files\Python36\lib\site-packages\supervisor\helpers.py", line 48, in kill2
    return self.taskkill()
  File "C:\Program Files\Python36\lib\site-packages\supervisor\helpers.py", line 54, in taskkill
    '/F', '/T'])
  File "C:\Program Files\Python36\lib\subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "C:\Program Files\Python36\lib\subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['taskkill', '/PID', '8772', '/F', '/T']' returned non-zero exit status 128.
alexsilva commented 4 years ago

phonebook something in that process prevents it from being stopped. I was unable to identify the problem because it is beyond the supervisor himself. It may be permission, some protection from the process itself. Even the task manager is unable to stop it!

alexsilva commented 4 years ago

Have you tried testing other simpler commands ? Like:

[program:cmd]
command=cmd.exe /c ping www.google.com -t
stdout_logfile=D:\build\supervisor\logs\%(program_name)s.log
stdout_logfile_maxbytes=50MB
redirect_stderr=true
environment=BUILD_LOG="C:\log"
stopasgroup=true
killasgroup=true
stopsignal=TERM
stopwaitsecs=30
pscholze commented 4 years ago

phonebook something in that process prevents it from being stopped. I was unable to identify the problem because it is beyond the supervisor himself. It may be permission, some protection from the process itself. Even the task manager is unable to stop it!

"mycommand" is only a dummy command due to legal restrictions on the part of our customer. When I start the process in a python script with subprocess.Popen and stop it and its children using SIGTERM, all works fine ...

alexsilva commented 4 years ago

This version of the supervisor starts the process with subprocess.Popen as well. I see no reason why it won't work.

#L380

Try disabling these options. They change the behavior of stopping a process.

stopasgroup=false killasgroup=false

alexsilva commented 4 years ago

@pscholze I made recent changes in the execution and management of processes. I suggest you update and run new tests.

alexsilva commented 4 years ago

Closing due to inactivity and lack of response.