Why is Invoke task reexecuted on code change?

19 Views Asked by At

I have defined Invoke task that runs foo function and then starts my Django app. Whenever I change the code, the whole task is reexecuted. I don't understand why reload mechanism triggers the task. I want foo function to be called only on docker-compose up. Can somebody explain?

Setup:

docker-compose.yml:

version: '3'
services:
  backend:
    entrypoint: ["invoke", "my_task"]
    volumes:
      - .:/code

tasks.py:

from invoke import task
import os
import django

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")
django.setup()

@task
def my_task(context):
    foo()
    management.call_command("runserver", "0.0.0.0:8000")
0

There are 0 best solutions below