Skip to content

Commit 649c4f9

Browse files
committed
Add HTTP server to provide status
1 parent 57b45d6 commit 649c4f9

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

production/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ If you use Docker in production, replace step 3 with:
3030

3131
```
3232
docker build . --tag my-temporal-worker --build-arg TEMPORAL_SERVER=host.docker.internal:7233
33-
docker run my-temporal-worker
33+
docker run -p 3000:3000 my-temporal-worker
3434
```
3535

3636
### Connecting to deployed Temporal Server

production/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
]
2222
},
2323
"dependencies": {
24-
"temporalio": "0.20.x"
24+
"micri": "^4.5.0",
25+
"temporalio": "^0.20.1"
2526
},
2627
"devDependencies": {
2728
"@tsconfig/node16": "^1.0.0",

production/src/worker.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { NativeConnection, Worker } from '@temporalio/worker';
2+
import { serve } from 'micri';
23
import * as activities from './activities';
34
import { connectionOptions, namespace } from './connection';
45

@@ -19,6 +20,20 @@ async function run() {
1920
taskQueue: 'production-sample',
2021
});
2122

23+
const server = serve(async () => {
24+
return worker.getStatus();
25+
});
26+
27+
server.listen(process.env.PORT || 3000);
28+
29+
server.on('error', (err) => {
30+
console.error(err);
31+
});
32+
33+
for (const signal of ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGUSR2']) {
34+
process.on(signal, () => server.close());
35+
}
36+
2237
await worker.run();
2338
}
2439
// @@@SNIPEND

0 commit comments

Comments
 (0)