Skip to main content

Run back-end in Host Mode

When developing an application, it is often important to easily test and debug it. For that matter, it is possible to run the Cartesi Rollups environment in host mode, so that the dApp's back-end can be executed directly on the host machine, allowing it to be debugged using regular development tools such as an IDE.

note

When running in host mode, localhost port 5004 will be used by default to allow the dApp's back-end to communicate with the Cartesi Rollups framework.

Step 1: Run the environment

The first step is to run the environment in host mode using the following command:

docker compose -f ../docker-compose.yml -f ./docker-compose.override.yml -f ../docker-compose-host.yml up

Step 2: Run the application back-end

The next step is to run the application back-end in your machine. For example, if the code is written in Python, you will need to have python3 installed.

In order to start the back-end, run the following commands in a dedicated terminal:

cd echo-python/
python3 -m venv .env
. .env/bin/activate
pip install -r requirements.txt
ROLLUP_HTTP_SERVER_URL="http://127.0.0.1:5004" python3 echo.py

Step 3: Check output

After the back-end successfully starts, it should print an output like the following:

INFO:__main__:HTTP rollup_server url is http://127.0.0.1:5004
INFO:__main__:Sending finish

Step 4: Interact with the application

After that, you can interact with the application normally as explained in the quick start article.

Options

How to automatically restart the back-end

The final command will effectively run the back-end and send corresponding outputs to port 5004. It can optionally be configured in an IDE to allow interactive debugging using features like breakpoints.

You can also use a tool like entr to restart the back-end automatically when the code changes. For example:

ls *.py | ROLLUP_HTTP_SERVER_URL="http://127.0.0.1:5004" entr -r python3 echo.py

How to stop containers

To stop the containers and remove any associated volumes, run the following command:

docker compose -f ../docker-compose.yml -f ./docker-compose.override.yml -f ../docker-compose-host.yml down -v

© 2024 Cartesi Foundation Ltd. All rights reserved.

The Cartesi Project is commissioned by the Cartesi Foundation.

We use cookies to ensure that we give you the best experience on our website. By using the website, you agree to the use of cookies.