Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WinSW Fails to Terminate Existing Nginx Process on Restart Command #1071

Open
screw-hand opened this issue Jan 15, 2024 · 0 comments
Open

WinSW Fails to Terminate Existing Nginx Process on Restart Command #1071

screw-hand opened this issue Jan 15, 2024 · 0 comments
Labels

Comments

@screw-hand
Copy link

Summary. The stop and restart commands provided by WinSW do not properly terminate the existing Nginx process. This leads to the creation of multiple Nginx processes upon executing a restart command, as the old process does not shut down. The issue is further confirmed by the tasklist output which shows multiple instances of nginx.exe after a restart, and the expected single process after using taskkill and then starting the service.

Steps to reproduce

  1. Start Nginx with WinSW using the E:\nginx-1.18.0\nginx-service.xml configuration.
  2. Perform changes to the Nginx configuration files.
  3. Use the restart command provided by WinSW to apply the changes and restart the service.
  4. Notice that the previous Nginx process does not terminate, resulting in multiple Nginx processes running simultaneously.

Environment

  • WinSW version: 2.12.00
  • WinSW package type: WinSW-x64.exe
  • Windows version: Windows Server 2008 R2 Enterprise
  • Wrapped executable and version: Nginx 1.18.0
<!-- E:\nginx-1.18.0\nginx-service.xml -->
<service>
    <id>nginx</id>
    <name>nginx</name>
    <description>This is an Nginx service managed by WinSW.</description>
    <logpath>E:\nginx-1.18.0\logs\</logpath>
    <logmode>roll</logmode>
    <executable>E:\nginx-1.18.0\nginx.exe</executable>
    <stopexecutable>E:\nginx-1.18.0\nginx.exe -s stop</stopexecutable>
</service>

Workaround and Issue Reporting Reason

The current workaround involves using taskkill /F /IM nginx.exe to forcefully terminate all instances of nginx.exe before starting the service again with nginx-service.exe start. However, this is not the best practice and can lead to data loss or corruption of the Nginx state. This behavior necessitates the reporting of this issue to seek a more graceful and reliable solution.

Command Output

E:\nginx-1.18.0>tasklist /fi "imagename eq nginx.exe"
信息: 没有运行的任务匹配指定标准。

E:\nginx-1.18.0>nginx-service.exe status
Stopped

E:\nginx-1.18.0>sc query nginx

SERVICE_NAME: nginx
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

E:\nginx-1.18.0>nginx-service.exe start
2024-01-15 16:58:38,252 INFO  - Starting service 'nginx (nginx)'...
2024-01-15 16:58:38,908 INFO  - Service 'nginx (nginx)' started successfully.

E:\nginx-1.18.0>tasklist /fi "imagename eq nginx.exe"

映像名称                       PID 会话名              会话#       内存使用
========================= ======== ================ =========== ============
nginx.exe                     1988 Services                   0      6,692 K
nginx.exe                     1716 Services                   0      6,988 K

E:\nginx-1.18.0>sc query nginx

SERVICE_NAME: nginx
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

E:\nginx-1.18.0>nginx-service.exe restart
2024-01-15 16:59:38,666 INFO  - Stopping service 'nginx (nginx)'...
2024-01-15 16:59:38,944 INFO  - Starting service 'nginx (nginx)'...
2024-01-15 16:59:40,118 INFO  - Service 'nginx (nginx)' restarted successfully.

E:\nginx-1.18.0>tasklist /fi "imagename eq nginx.exe"

映像名称                       PID 会话名              会话#       内存使用
========================= ======== ================ =========== ============
nginx.exe                     1716 Services                   0      6,968 K
nginx.exe                    10416 Services                   0      6,692 K
nginx.exe                     6728 Services                   0      6,984 K

E:\nginx-1.18.0>:: why have three process, here?

Workaround and Issue Reporting Reason

The current workaround involves using taskkill /F /IM nginx.exe to forcefully terminate all instances of nginx.exe before starting the service again with nginx-service.exe start. However, this is not the best practice and can lead to data loss or corruption of the Nginx state. This behavior necessitates the reporting of this issue to seek a more graceful and reliable solution.

E:\nginx-1.18.0>taskkill /F /IM nginx.exe
成功: 已终止进程 "nginx.exe",其 PID 为 1716。
成功: 已终止进程 "nginx.exe",其 PID 为 10416。
成功: 已终止进程 "nginx.exe",其 PID 为 6728。

E:\nginx-1.18.0>nginx-service.exe start
2024-01-15 17:03:59,517 INFO  - Starting service 'nginx (nginx)'...
2024-01-15 17:04:00,165 INFO  - Service 'nginx (nginx)' started successfully.

E:\nginx-1.18.0>tasklist /fi "imagename eq nginx.exe"

映像名称                       PID 会话名              会话#       内存使用
========================= ======== ================ =========== ============
nginx.exe                     8128 Services                   0      6,692 K
nginx.exe                     1076 Services                   0      6,988 K

E:\nginx-1.18.0>

Additional Information

I'm willing to provide further details like logs or any other information that may be missing from this report. Thank you to all the coders who take the time to look into this issue.

@screw-hand screw-hand added the bug label Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant