Skip to main content

How to run

For help running services you can run ./run-helper script, it will say you what you need in order to start lambda functions locally. If you want to enable hot-reload changes, you need to keep the following points in mind: Pre-requirements

  • Run workflow_executor service
  • Run sqs locally in docker-compose docker-compose up -d sqs . Open localhost:9325 to see created queues
  • Create workflow with action that you debugging and set serverless mode on (isServerless in database to true)
  • Send request to execute this workflow Next steps can vary based on what type of app you are working:
  1. You are working on non-container(ZIP) lambda function
  • run nx run actions-{type}-{group-name}:serve - it will run Lambda in watching mode
  • Ensure that in your app's project.json file, in serve target --reloadHandler option is there. it should be like that: "sls offline --stage=offline start --reloadHandler "

This option force lambda's code reload in memory each time it's called (you can think about it as cold start), if you don't need to modify code of this function you can delete this option and it'll decrease execution time (will execute faster).

  1. You are working on container(Docker) lambda function For local development, serverless-offline plugin doesn't support Docker's lambda, for that purposes was created additional listener to the queue that sends requests to Docker container.
  • Run nx run actions-{type}-{group-name}:serve command, this command simple run code watcher, that rebuild dist each time you modify code and run additional apps for local development (if any)

  • Second command that need to be run is docker-compose up {group-name} It'll build and run container for your needs and point to dist folder that updating each time you modify your code

  • WARNING: It work similar to ZIP lambda, it loads the code and doesn't automatically reload once you changed your code, so you need to stop the container and run it again otherwise it will use preloaded code. It would be nice to find how we can automate this operation or fix this bug .

  1. You are working on Fargate task Since Fargate doesn't run on lambda we need to implement logic for getting/receiving messages from SQS by ourself. And it means that for running locally we can just change the env variables to point to local SQS instead of remote.
    • Run nx run actions-{type}-{group-name}:serve to start code-watcher.
    • Run docker-compose up {group-name}
    • WARNING similar to docker in point 2 it doesn't work without reload, we haven't dive deep in details why, so it's an open issue. In order to get your changes you need to restart docker container