Skip to content

Feature Request: Implement Graceful Shutdown for Garnet as a Windows Service #1382

@yuseok-kim-edushare

Description

@yuseok-kim-edushare

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:

  1. The Garnet.Worker service intercepts the stop signal from Windows.
  2. Before terminating the process, the service issues a SAVE command to the Garnet server to ensure all data is flushed to disk.
  3. 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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions