-
Notifications
You must be signed in to change notification settings - Fork 606
Description
Feature request type
enhancement
Is your feature request related to a problem? Please describe
When Garnet is run as a Windows Service using Garnet.Worker.exe
, it shuts down immediately upon receiving a stop signal from the Service Control Manager (e.g., via services.msc
or sc stop
).
This behavior can lead to data loss for any in-memory data that has not yet been persisted to disk through the AOF or a recent checkpoint. A graceful shutdown mechanism is needed to ensure data integrity.
Describe the solution you'd like
The Garnet.Worker
service host should properly handle the OnStop
event from the Windows Service base class. The desired workflow is as follows:
- The
Garnet.Worker
service intercepts the stop signal from Windows. - Before terminating the process, the service issues a
SAVE
command to the Garnet server to ensure all data is flushed to disk. - The service should wait for the save operation to complete successfully before allowing the process to exit.
Describe alternatives you've considered
The current alternative is to manually connect to the Garnet instance with a client (e.g., redis-cli
) and issue a SAVE
command before stopping the service. This is not ideal for automated environments and is prone to human error.
Additional context
For context, here is how the Garnet Windows Service is being created:
set SVCEXE="C:\garnet\Service\Garnet.Worker.exe"
sc create Garnet binPath= "%SVCEXE% --config-import-path \"C:\Garnet\garnet.conf\"" start= auto
sc description Garnet "Garnet (RESP) with storage+AOF+compaction"