From d3b12897dae61be71bade2fd3a784cc8f8ee5d8d Mon Sep 17 00:00:00 2001 From: Michael Matloka Date: Tue, 17 Dec 2024 20:00:05 +0100 Subject: [PATCH] Add /etc/hosts fix and initial pnpm install --- .flox/env/manifest.lock | 10 +++++----- .flox/env/manifest.toml | 26 ++++++++++++++++++++++---- bin/temporal-django-worker | 2 +- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.flox/env/manifest.lock b/.flox/env/manifest.lock index 03f280d2b9833..7768f6793c35e 100644 --- a/.flox/env/manifest.lock +++ b/.flox/env/manifest.lock @@ -70,13 +70,13 @@ "POSTHOG_SKIP_MIGRATION_CHECKS": "1" }, "hook": { - "on-activate": "export CARGO_HOME=\"$FLOX_ENV_CACHE/cargo\"\nexport PATH=\"$CARGO_HOME/bin:$PATH\"\n\n# Set up a Python virtual environment\nexport PYTHON_DIR=\"$FLOX_ENV_CACHE/venv\"\nuv venv \"$PYTHON_DIR\" --allow-existing\n\nsource \"$PYTHON_DIR/bin/activate\"\n\n# Install Python dependencies (this is practically instant thanks to uv)\nuv pip install -q -r requirements.txt -r requirements-dev.txt\n" + "on-activate": "export CARGO_HOME=\"$FLOX_ENV_CACHE/cargo\"\nexport PATH=\"$CARGO_HOME/bin:$PATH\"\n\n# Set up a Python virtual environment\nexport PYTHON_DIR=\"$FLOX_ENV_CACHE/venv\"\nuv venv \"$PYTHON_DIR\" --allow-existing\necho -e \"Python interpreter path for your code editor: \\033[32m.flox/cache/venv/bin/python\\033[0m\"\n\nsource \"$PYTHON_DIR/bin/activate\"\n\n# Install Python dependencies (this is practically instant thanks to uv)\nuv pip install -q -r requirements.txt -r requirements-dev.txt\n\n# Install top-level Node dependencies (only if not present all yet, because this takes almost a second even with pnpm)\n# This also sets up pre-commit hooks via Husky\nif [ ! -d \"node_modules\" ]; then\n pnpm install -s\nfi\n\n# Add required entries to /etc/hosts if not present\nif ! grep -q \"127.0.0.1 kafka clickhouse\" /etc/hosts; then\n echo \"\"\n echo \"šŸšØ Amending /etc/hosts to map hostnames 'kafka' and 'clickhouse' to 127.0.0.1...\"\n echo \"127.0.0.1 kafka clickhouse\" | sudo tee -a /etc/hosts 1> /dev/null\n echo \"āœ… /etc/hosts amended\"\nfi\n\necho -e \"\nšŸ‘‰ IT'S DANGEROUS TO GO ALONE! RUN THIS:\n\\033[38;2;255;0;0m1.\\033[0m bin/migrate - to run all migrations\n\\033[38;2;0;255;0m2.\\033[0m bin/start - to start the entire stack\n\\033[38;2;0;0;255m3.\\033[0m ./manage.py generate_demo_data - to create a user with demo data\n\"\n" }, "profile": { - "bash": " source \"$PYTHON_DIR/bin/activate\"\n cat .flox/env/greeting.txt\n", - "zsh": " source \"$PYTHON_DIR/bin/activate\"\n cat .flox/env/greeting.txt\n", - "fish": " source \"$PYTHON_DIR/bin/activate.fish\"\n cat .flox/env/greeting.txt\n", - "tcsh": " source \"$PYTHON_DIR/bin/activate.csh\"\n cat .flox/env/greeting.txt\n" + "bash": " source \"$PYTHON_DIR/bin/activate\"\n", + "zsh": " source \"$PYTHON_DIR/bin/activate\"\n", + "fish": " source \"$PYTHON_DIR/bin/activate.fish\"\n", + "tcsh": " source \"$PYTHON_DIR/bin/activate.csh\"\n" }, "options": { "systems": [ diff --git a/.flox/env/manifest.toml b/.flox/env/manifest.toml index c04b65d8416bb..0b22c9a89883b 100644 --- a/.flox/env/manifest.toml +++ b/.flox/env/manifest.toml @@ -54,11 +54,33 @@ export PATH="$CARGO_HOME/bin:$PATH" # Set up a Python virtual environment export PYTHON_DIR="$FLOX_ENV_CACHE/venv" uv venv "$PYTHON_DIR" --allow-existing +echo -e "Python interpreter path for your code editor: \033[32m.flox/cache/venv/bin/python\033[0m" source "$PYTHON_DIR/bin/activate" # Install Python dependencies (this is practically instant thanks to uv) uv pip install -q -r requirements.txt -r requirements-dev.txt + +# Install top-level Node dependencies (only if not present all yet, because this takes almost a second even with pnpm) +# This also sets up pre-commit hooks via Husky +if [ ! -d "node_modules" ]; then + pnpm install -s +fi + +# Add required entries to /etc/hosts if not present +if ! grep -q "127.0.0.1 kafka clickhouse" /etc/hosts; then + echo "" + echo "šŸšØ Amending /etc/hosts to map hostnames 'kafka' and 'clickhouse' to 127.0.0.1..." + echo "127.0.0.1 kafka clickhouse" | sudo tee -a /etc/hosts 1> /dev/null + echo "āœ… /etc/hosts amended" +fi + +echo -e " +šŸ‘‰ IT'S DANGEROUS TO GO ALONE! RUN THIS: +\033[38;2;255;0;0m1.\033[0m bin/migrate - to run all migrations +\033[38;2;0;255;0m2.\033[0m bin/start - to start the entire stack +\033[38;2;0;0;255m3.\033[0m ./manage.py generate_demo_data - to create a user with demo data +" ''' # Scripts defined in the `[profile]` section are *sourced* by *your shell* and @@ -69,19 +91,15 @@ uv pip install -q -r requirements.txt -r requirements-dev.txt [profile] bash = ''' source "$PYTHON_DIR/bin/activate" - cat .flox/env/greeting.txt ''' fish = ''' source "$PYTHON_DIR/bin/activate.fish" - cat .flox/env/greeting.txt ''' tcsh = ''' source "$PYTHON_DIR/bin/activate.csh" - cat .flox/env/greeting.txt ''' zsh = ''' source "$PYTHON_DIR/bin/activate" - cat .flox/env/greeting.txt ''' # The `[services]` section of the manifest allows you to define services. diff --git a/bin/temporal-django-worker b/bin/temporal-django-worker index 27259dc3f13e7..dab9cea663fbd 100755 --- a/bin/temporal-django-worker +++ b/bin/temporal-django-worker @@ -13,7 +13,7 @@ cleanup() { trap cleanup SIGINT SIGTERM EXIT -python manage.py start_temporal_worker "$@" +python manage.py start_temporal_worker "$@" & worker_pid=$!