Fixing monitor to use new venv.

This commit is contained in:
Samuel Clay 2024-12-24 22:43:01 -05:00
parent 6c5aed53eb
commit e55e6c3bd5
4 changed files with 23 additions and 15 deletions

View file

@ -15,7 +15,7 @@
lineinfile:
path: /srv/newsblur/newsblur_web/app_env.py
line: 'SERVER_NAME = "{{ inventory_hostname }}"'
- name: Start monitor docker container
become: yes
docker_container:
@ -23,7 +23,7 @@
image: newsblur/newsblur_monitor:latest
pull: yes
state: started
command: bash -c "python /srv/newsblur/flask_monitor/db_monitor.py"
command: bash -c "/venv/bin/python /srv/newsblur/flask_monitor/db_monitor.py"
hostname: "{{ inventory_hostname }}"
restart_policy: unless-stopped
container_default_behavior: no_defaults

View file

@ -23,14 +23,22 @@ RUN set -ex \
zlib1g-dev \
' \
&& apt-get update \
&& apt-get install -y $rundDeps $buildDeps --no-install-recommends \
&& pip install uv \
&& uv clean || true \
&& rm -rf /venv \
&& uv venv /venv \
&& PATH="/venv/bin:$PATH" \
&& VIRTUAL_ENV="/venv" \
&& rm -rf /root/.cache/uv \
&& uv pip install -r requirements.txt \
&& apt-get purge -y --auto-remove ${buildDeps} \
&& rm -rf /var/lib/apt/lists/*
&& apt-get install -y $rundDeps $buildDeps --no-install-recommends
# Install uv
RUN pip install uv
# Clean uv cache and any virtual environment from previous builds
RUN uv clean || true && rm -rf /venv
# Create and activate virtual environment in /venv
RUN uv venv /venv
ENV PATH="/venv/bin:$PATH"
ENV VIRTUAL_ENV="/venv"
# Install dependencies
RUN rm -rf /root/.cache/uv && \
uv pip install -r requirements.txt
RUN apt-get purge -y --auto-remove ${buildDeps}
RUN rm -rf /var/lib/apt/lists/*

View file

@ -256,7 +256,7 @@ def db_check_redis_pubsub():
@app.route("/db_check/elasticsearch")
def db_check_elasticsearch():
try:
conn = elasticsearch.Elasticsearch(f"{settings.SERVER_NAME}.node.nyc1.consul:9200")
conn = elasticsearch.Elasticsearch(f"http://{settings.SERVER_NAME}.node.nyc1.consul:9200")
except:
abort(Response("Can't connect to db", 503))

View file

@ -2,7 +2,7 @@ flask>=2,<3
pymongo>=3.11.2,<4
psycopg2>=2,<3
redis==3.5.3
elasticsearch>=7,<8
elasticsearch>=8,<9
pymysql==0.10.1
celery>=4,<5
Django>=3.1,<3.2