hasura / hasura/graphql-engine

graphql-engine v2 container image reacts to SIGTERM to avoid SIGKILL

Open
#10,284 1 comment 1 reaction 0 assignees View on GitHub
k/enhancement
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Is your proposal related to a problem?

When stopping a container that is based on `hasura/graphql-engine` it takes 10 seconds, until the container scheduler issues SIGKILL.

Reacting to SIGTERM would allow to shut down the process gracefully.

### Describe the solution you'd like

The process launched by the image built from https://github.com/hasura/graphql-engine/blob/master/packaging/graphql-engine/Dockerfile reacts to SIGTERM signals.

This could be achieved by providing the `tini` binary in the container image and using that to launch the entrypoint command.

### Describe alternatives you've considered

Users of the container can always use the `--init` flag of the `run` command to wrap `tini` around the entrypoint.

- https://docs.docker.com/reference/cli/docker/container/run/#init

This is also available for Docker Compose when providing the `init: true` property to services.

- https://docs.docker.com/compose/compose-file/05-services/#init

In case this behaviour is preferred, it should be documented.

## Example:

After launching the containers once without and once with the `init` flag, the shutdown times differ greatly:

```sh
$ docker compose stop
[+] Stopping 1/1
✔ Container hasura-console-1 Stopped 10.2s
```

The need for using an init process to catch signals is visible by a shutdown time of almost exactly 10 seconds.

```sh
$ docker compose stop
[+] Stopping 1/1
✔ Container hasura-console-1 Stopped 0.2s
```

It's either the `init` workaround with `tini`, that should be documented, or explicit signal handling in the `graphql-engine` binary which could help alleviate the situation.

Contributor guide

Open the contributing guide

Research direction

Start with packaging/graphql-engine/Dockerfile and compare the container's current entrypoint behavior with the documented Docker --init and Compose init: true alternatives. Verify the SIGTERM shutdown timing with docker compose stop, then determine whether the image should include tini or the workaround should be documented; done means the chosen approach avoids the observed 10-second SIGKILL delay.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, graphql
Domain
devops, infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.