Skip to content

Commit 023c751

Browse files
author
Mrunal Patel
committed
Merge pull request #202 from LK4D4/post_start
Add post-start hooks
2 parents 2078b31 + 8c7b01b commit 023c751

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

runtime-config.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
## Hooks
44

55
Lifecycle hooks allow custom events for different points in a container's runtime.
6-
Presently there are `Prestart` and `Poststop`.
6+
Presently there are `Prestart`, `Poststart` and `Poststop`.
77

88
* [`Prestart`](#pre-start) is a list of hooks to be run before the container process is executed
9+
* [`Poststart`](#post-start) is a list of hooks to be run immediately after the container process is started
910
* [`Poststop`](#post-stop)is a list of hooks to be run after the container process exits
1011

1112
Hooks allow one to run code before/after various lifecycle events of the container.
@@ -22,6 +23,13 @@ In Linux, for e.g., the network namespace could be configured in this hook.
2223

2324
If a hook returns a non-zero exit code, then an error including the exit code and the stderr is returned to the caller and the container is torn down.
2425

26+
### Post-start
27+
28+
The post-start hooks are called after the user process is started.
29+
For example this hook can notify user that real process is spawned.
30+
31+
If a hook returns a non-zero exit code, then an error is logged and the remaining hooks are executed.
32+
2533
### Post-stop
2634

2735
The post-stop hooks are called after the container process is stopped.
@@ -42,6 +50,11 @@ If a hook returns a non-zero exit code, then an error is logged and the remainin
4250
"path": "/usr/bin/setup-network"
4351
}
4452
],
53+
"poststart": [
54+
{
55+
"path": "/usr/bin/notify-start",
56+
},
57+
],
4558
"poststop": [
4659
{
4760
"path": "/usr/sbin/cleanup.sh",

runtime_config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ type Hooks struct {
2222
// Prestart is a list of hooks to be run before the container process is executed.
2323
// On Linux, they are run after the container namespaces are created.
2424
Prestart []Hook `json:"prestart"`
25+
// Poststart is a list of hooks to be run after the container process is started.
26+
Poststart []Hook `json:"poststart"`
2527
// Poststop is a list of hooks to be run after the container process exits.
2628
Poststop []Hook `json:"poststop"`
2729
}

0 commit comments

Comments
 (0)