Skip to content

Commit

Permalink
switch to busybox and only call post start hook for restore (#1005)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicktrn committed Apr 5, 2024
1 parent e35f297 commit f2894c1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-ducks-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---

Fix post start hooks
17 changes: 10 additions & 7 deletions apps/kubernetes-provider/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,6 @@ class KubernetesTaskOperations implements TaskOperations {
},
},
lifecycle: {
postStart: {
exec: {
command: this.#getLifecycleCommand("postStart", "create"),
},
},
preStop: {
exec: {
command: this.#getLifecycleCommand("preStop", "terminate"),
Expand Down Expand Up @@ -404,11 +399,19 @@ class KubernetesTaskOperations implements TaskOperations {
type: THookType,
cause: THookType extends "postStart" ? PostStartCauses : PreStopCauses
) {
const retries = 5
const retries = 5;

// This will retry sending the lifecycle hook up to `retries` times
// The sleep is required as this may start running before the HTTP server is up
return ["/bin/sh", "-c", `for i in $(seq ${retries}); do sleep 1; wget -q -O- 127.0.0.1:8000/${type}?cause=${cause} && break; done`];
const exec = [
"/bin/sh",
"-c",
`for i in $(seq ${retries}); do sleep 1; busybox wget -q -O- 127.0.0.1:8000/${type}?cause=${cause} && break; done`,
];

logger.log("getLifecycleCommand()", { exec });

return exec;
}

#getIndexContainerName(suffix: string) {
Expand Down
5 changes: 4 additions & 1 deletion packages/cli-v3/src/Containerfile.prod
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM node:20-bookworm-slim@sha256:d4cdfc305abe5ea78da7167bf78263c22596dc332f2654b662890777ea166224 AS base

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends dumb-init && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y --no-install-recommends \
busybox \
dumb-init \
&& rm -rf /var/lib/apt/lists/*

# Create and set workdir with appropriate permissions
RUN mkdir /app && chown node:node /app
Expand Down

0 comments on commit f2894c1

Please sign in to comment.