I originally also had worker.shutdown(), but my impression is that on a SIGINT/SIGTERM, the worker will automatically transition to a shutting down stage, so this isn’t necessary. Along those lines, if I await the workerPromise, do I also need to have another call to close the connection?
The worker already listens for these signals for you, you don’t need to do any of that.
You should close the connection though after the run promise is resolved.
So you’re saying that the revised block of code doesn’t need a listener for the SIGTERM? So instead it can just look like:
export default async function run() {
connection = await NativeConnection.connect();
const worker = await Worker.create({
activities: getAllActivities(),
connection,
taskQueue: 'test',
});
workerPromise = worker.run();
await workerPromise;
await connection.close();
// any other things I might want to handle here like closing other DB connections
}
Also I’m not completely clear on what the docs you linked are supposed to indicate, could you elaborate? I thought made more sense, but perhaps I’m not understanding completely. Thanks!