Skip to content

Commit

Permalink
Fix "cancelled on client" moving workflow.stop out to SIGTERM handler
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Yuknewicz <[email protected]>
  • Loading branch information
paulyuk committed Jul 29, 2024
1 parent 4e70fad commit 74e2a59
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions workflows/javascript/sdk/order-processor/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { DaprWorkflowClient, WorkflowRuntime, DaprClient, CommunicationProtocolE
import { InventoryItem, OrderPayload } from "./model";
import { notifyActivity, orderProcessingWorkflow, processPaymentActivity, requestApprovalActivity, reserveInventoryActivity, updateInventoryActivity } from "./orderProcessingWorkflow";

const workflowWorker = new WorkflowRuntime();

async function start() {
// Update the gRPC client and worker to use a local address and port
const workflowClient = new DaprWorkflowClient();
const workflowWorker = new WorkflowRuntime();


const daprHost = process.env.DAPR_HOST ?? "127.0.0.1";
const daprPort = process.env.DAPR_GRPC_PORT ?? "50001";
Expand Down Expand Up @@ -60,10 +62,13 @@ async function start() {
throw error;
}

await workflowWorker.stop();
await workflowClient.stop();
}

process.on('SIGTERM', () => {
workflowWorker.stop();
})

start().catch((e) => {
console.error(e);
process.exit(1);
Expand Down

0 comments on commit 74e2a59

Please sign in to comment.