import { WorkflowClient } from '@temporalio/client' ; import { scheduledWorkflow } from './workflows' ; const workflowId = 'my-schedule' ; async function run ( ) { const client = new WorkflowClient ( ) ; const handle = await client . start ( scheduledWorkflow , { taskQueue : 'cron-workflows' , workflowId : 'my-schedule' , cronSchedule : '* * * * *' , args : [ 'Temporal' ] , } ) ; console . log ( 'Cron started' ) ; try { await handle . result ( ) ; } catch ( err ) { console . error ( err . message + ':' + handle . workflowId ) ; } } process . on ( 'SIGINT' , async ( ) => { const client = new WorkflowClient ( ) ; const handle = client . getHandle ( workflowId ) ; await handle . cancel ( ) ; console . log ( `\nCanceled Workflow ${ handle . workflowId }` ) ; process . exit ( 0 ) ; } ) ; run ( ) . catch ( ( err ) => { console . error ( err ) ; process . exit ( 1 ) ; } ) ;