Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reworked javascript workflow examples to use a webserver #1039

Merged
merged 7 commits into from
Jul 30, 2024
Merged
Prev Previous commit
Fix "cancelled on client" moving workflow.stop out to SIGTERM handler
Signed-off-by: Paul Yuknewicz <paulyuk@microsoft.com>
  • Loading branch information
paulyuk committed Jul 29, 2024
commit 74e2a59a5795de9f1b193aa52dadeb2d3e9be5c9
9 changes: 7 additions & 2 deletions workflows/javascript/sdk/order-processor/app.ts
Original file line number Diff line number Diff line change
@@ -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";
@@ -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);