# Multiple Flows

Running an in-process agent is simple when developing a single flow. A more scalable approach is to use the CLI to run a standalone local agent that can execute multiple flows at a time scheduled by the Prefect API.

# Run an Agent Manually

Let's introduce another flow for this tutorial:

import prefect
from prefect import task, Flow

def another_task():
    logger = prefect.context.get("logger")
    logger.info("Our second Flow!")

flow = Flow("second-flow", tasks=[another_task])

flow.register(project_name="Hello, World!")

In another terminal, start the local agent:

prefect agent start

Runner Token Cloud

This Local Agent will use the RUNNER token stored in your environment but if you want to manually pass it a token you may do so with --token <COPIED_RUNNER_TOKEN>.

Now you have a local agent running which can execute multiple flows that you register with the Prefect API:

prefect run flow --name hello-flow --project 'Hello, World!'
prefect run flow --name second-flow --project 'Hello, World!'

# Install a Supervised Agent

The standalone local agent is ideal for executing flows decoupled from the scripts defining these flows. To install the CLI agent in an always-running capacity we recommend using Supervisor to monitor the local agent:

pip install supervisor

Note: For more information on Supervisor installation visit the documentation.

The Prefect CLI has an installation command for the local agent which will output a supervisord.conf file that you can save and run using Supervisor.

prefect agent install local --token <YOUR_RUNNER_TOKEN> > supervisord.conf

No token necessary for Core server

If you are using Prefect Core's server then no --token is necessary for this step.

In that same directory as the supervisord.conf file you may start Supervisor.


Your Local Agent is now up and running in the background with Supervisor! For more information on the Local Agent and using it with Supervisor visit the documentation.