We use cookies

We use cookies to ensure you get the best experience on our website. For more information on how we use cookies, please see our cookie policy.

By clicking "Accept", you agree to our use of cookies.
Learn more.

CLI ReferenceRunning Workers Locally

Running Workers Locally

The Hatchet CLI provides the hatchet worker commands to run Hatchet workers locally for development and testing purposes.

Setting up a hatchet.yaml file

If you’ve set up a project using hatchet quickstart, a hatchet.yaml file is already created for you in the project directory.

The hatchet worker commands rely on a hatchet.yaml configuration file to define the worker settings. You can create a hatchet.yaml file in your project directory which resembles the following (you will need to adjust the preCmds and runCmd fields to match your project’s setup):

dev:
  preCmds: ["poetry install"]
  runCmd: "poetry run python src/worker.py"
  files:
    - "**/*.py"
    - "!**/__pycache__/**"
    - "!**/.venv/**"
  reload: true

Running a worker

Once you have a hatchet.yaml file set up, you can run a worker locally using the following command:

hatchet worker dev

To run a worker with a specific profile, you can run:

hatchet worker dev --profile <profile-name>

Disabling auto-reload

If you want to run the worker without auto-reloading on file changes, you can set the dev.reload field to false in your hatchet.yaml file:

dev:
  reload: false

Or you can pass the --no-reload flag when running the worker:

hatchet worker dev --no-reload

Overriding the run command

You can override the runCmd specified in the hatchet.yaml file by using the --run-cmd flag:

hatchet worker dev --run-cmd "npm run dev"