cloudflare / cloudflare/workerd

[Container] exit behavior

Open
#4,433 1 comment 0 reactions 1 assignee Claimed by @anonrig View on GitHub
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

I just noticed that we use on [`on-failure` restart policy](https://docs.docker.com/engine/containers/start-containers-automatically/#use-a-restart-policy):

https://github.com/cloudflare/workerd/blob/7222f4fba281e760835142e5d9fab8a8c0efacb5/src/workerd/server/container-client.c%2B%2B#L285-L287

This means that the container will automatically restart if the exit code is non zero.

@gabivlj does it match what we do in prod?

The use case I'm thinking of is a CI job which would 0 exit on success an non-0 exit on failure.
There should be no reason to automatically restart the container on failure in this case.

The comment on `monitor` makes me think that non success status can happen and should be handled there:

```
# container.capnp
monitor @2 ();
# Waits for the container to shut down.
#
# If the container shuts down because the root process exited with a success status, or because
# the client invoked `destroy()`, then `monitor()` completes without an error. If it shuts down
# for any other reason, `monitor()` throws an exception describing what happened. (This exception
# may or may not be a JSG exception depending on whether it is an application error or a system
# error.)
```

/cc @anonrig @emily-shen @mikenomitch

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.