Skip to content

Commit a2ed8f2

Browse files
committed
refactor: Make outbox wait several for 5 seconds before retry
1 parent 354b684 commit a2ed8f2

4 files changed

Lines changed: 35 additions & 18 deletions

File tree

backend/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ COPY --from=prerelease /usr/src/pylon/.pylon .pylon
4141
COPY --from=prerelease /usr/src/pylon/package.json .
4242
COPY --from=prerelease /usr/src/pylon/src src
4343
COPY --from=prerelease /usr/src/pylon/tsconfig.json tsconfig.json
44+
COPY --from=prerelease /usr/src/pylon/migrations migrations
4445

4546
# run the app
4647
USER bun

backend/src/workers/OutboxProcessor.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export default class OutboxProcessor {
2121
await this.producer
2222
.connect()
2323
.then(() => console.log("Producer successfully connected"));
24-
2524
const interval = this.intervalMs;
2625

2726
const run = async () => {

backend/src/workers/run_outbox_processor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ const outbox_processor = new OutboxProcessor(
1515
1000
1616
);
1717

18-
await outbox_processor.start();
18+
await outbox_processor.start(); // blocks until failure or completion

docker-compose.yml

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,29 @@ services:
2525
- POSTGRES_PORT
2626
- JWT_SECRET
2727
- KAFKA_URL=kafka:9092
28-
command: sh -c "sleep 5 && bun run outbox"
28+
command: bun run outbox
29+
restart: unless-stopped
2930
depends_on:
3031
- postgres
3132
- kafka
3233
networks:
3334
- mynet
35+
36+
init_db:
37+
build: ./backend
38+
environment:
39+
- POSTGRES_USER
40+
- POSTGRES_PASSWORD
41+
- POSTGRES_NAME
42+
- POSTGRES_HOST
43+
- POSTGRES_PORT
44+
- JWT_SECRET
45+
- KAFKA_URL=kafka:9092
46+
command: bun run init_db
47+
depends_on:
48+
- postgres
49+
networks:
50+
- mynet
3451
postgres:
3552
image: postgres:16
3653
container_name: postgres_db
@@ -137,21 +154,21 @@ services:
137154
networks:
138155
- mynet
139156

140-
analytics_job:
141-
build: ./analytics/
142-
depends_on:
143-
- jobmanager
144-
- kafka
145-
command: >
146-
bash -c "
147-
echo 'Waiting for JobManager...';
148-
sleep 5;
149-
/opt/flink/bin/flink run \
150-
-m jobmanager:8081 \
151-
/opt/flink/usrlib/*.jar
152-
"
153-
networks:
154-
- mynet
157+
# analytics_job:
158+
# build: ./analytics/
159+
# depends_on:
160+
# - jobmanager
161+
# - kafka
162+
# command: >
163+
# bash -c "
164+
# echo 'Waiting for JobManager...';
165+
# sleep 5;
166+
# /opt/flink/bin/flink run \
167+
# -m jobmanager:8081 \
168+
# /opt/flink/usrlib/*.jar
169+
# "
170+
# networks:
171+
# - mynet
155172

156173
volumes:
157174
postgres_data:

0 commit comments

Comments
 (0)