mtkennerly / shawl

Windows service wrapper for arbitrary commands
MIT License
448 stars 15 forks source link

Some programs don't end gracefully. #48

Open Lixuhuilll opened 3 months ago

Lixuhuilll commented 3 months ago

I am trying to run a non-native Redis service in a local development environment. It starts normally, but it doesn't end gracefully, Ctrl-C doesn't seem to work.

I use the following command to create the service. shawl.exe add --name Redis --cwd D:\programs\Redis -- redis-server.exe redis.conf

When I run redis-service.exe redis.confdirectly, Ctrl-C is valid, and when I press it produces the following output.

166:M 27 Mar 2024 15:17:29.284 * Server initialized
166:M 27 Mar 2024 15:17:29.284 * Loading RDB produced by version 7.2.4
166:M 27 Mar 2024 15:17:29.284 * RDB age 577 seconds
166:M 27 Mar 2024 15:17:29.285 * RDB memory usage when created 0.54 Mb
166:M 27 Mar 2024 15:17:29.285 * Done loading RDB, keys loaded: 0, keys expired: 0.
166:M 27 Mar 2024 15:17:29.285 * DB loaded from disk: 0.001 seconds
166:M 27 Mar 2024 15:17:29.285 * Ready to accept connections tcp
166:signal-handler (1711523851) Received SIGINT scheduling shutdown...
166:M 27 Mar 2024 15:17:31.392 * User requested shutdown...
166:M 27 Mar 2024 15:17:31.393 * Saving the final RDB snapshot before exiting.
166:M 27 Mar 2024 15:17:31.397 * DB saved on disk
166:M 27 Mar 2024 15:17:31.397 * Removing the pid file.
166:M 27 Mar 2024 15:17:31.397 # Redis is now ready to exit, bye bye...

And if I start the service through shawl, when I end the service, the output looks like this.

2024-03-27 15:54:43 [DEBUG] stdout: "1789:M 27 Mar 2024 15:54:43.279 * Server initialized"
2024-03-27 15:54:43 [DEBUG] stdout: "1789:M 27 Mar 2024 15:54:43.280 * Loading RDB produced by version 7.2.4"
2024-03-27 15:54:43 [DEBUG] stdout: "1789:M 27 Mar 2024 15:54:43.280 * RDB age 1906 seconds"
2024-03-27 15:54:43 [DEBUG] stdout: "1789:M 27 Mar 2024 15:54:43.280 * RDB memory usage when created 0.54 Mb"
2024-03-27 15:54:43 [DEBUG] stdout: "1789:M 27 Mar 2024 15:54:43.280 * Done loading RDB, keys loaded: 0, keys expired: 0."
2024-03-27 15:54:43 [DEBUG] stdout: "1789:M 27 Mar 2024 15:54:43.280 * DB loaded from disk: 0.000 seconds"
2024-03-27 15:54:43 [DEBUG] stdout: "1789:M 27 Mar 2024 15:54:43.280 * Ready to accept connections tcp"
2024-03-27 15:54:51 [INFO] Received stop event
2024-03-27 15:54:51 [INFO] Sending ctrl-C to command
2024-03-27 15:54:54 [INFO] Killing command because stop timeout expired
2024-03-27 15:54:54 [DEBUG] Exited main service loop
2024-03-27 15:54:54 [DEBUG] Finished successfully

I don't know what caused the difference. Did I use the wrong command?

mtkennerly commented 2 months ago

Hi! I'm not sure why that's happening, but I can try to find out.

When you say "non-native", do you mean you're doing something with WSL, or is it a 32-bit exe on a 64-bit host?

I'd like to try to reproduce this on my system. Could you tell me where you got redis-server.exe (there seem to be a few different ports out there) and the content of your redis.conf?