Compare commits

...

11 Commits

Author SHA1 Message Date
Maxi Quoß 1de1d407a3 v1.0.5 2021-10-15 02:26:04 +02:00
Maxi Quoß 088eee39e1 set healthcheck in dockerfile 2021-10-15 02:25:33 +02:00
Maxi Quoß f179450e3b v1.0.4 2021-10-15 01:18:39 +02:00
Maxi Quoß f1a8fe9dbe restart unless-stopped, fix pg_isready user 2021-10-15 01:16:03 +02:00
Maxi Quoß 63beff0bca prevent ping interval < 5 sec 2021-10-15 01:15:38 +02:00
Maxi Quoß dd2be0946c add docker health status, keep python3.9: deps not updated for 3.10 yet 2021-10-15 00:52:25 +02:00
Maxi Quoß 9484e40815 Revert "wol"
This reverts commit 9c1abb45a8.
2021-10-05 23:16:52 +02:00
Maxi Quoß 9c1abb45a8 wol 2021-10-05 23:11:56 +02:00
Maxi Quoß c6286595b8 v1.0.3 2021-10-05 23:06:32 +02:00
Maxi Quoß 5a11bb7c58 yeaaaah lets change margins again 2021-10-05 23:01:15 +02:00
Maxi Quoß 036c931aef settings: headlines margin top and bottom 2021-10-05 22:50:32 +02:00
7 changed files with 45 additions and 18 deletions
+6 -3
View File
@@ -1,4 +1,4 @@
FROM python:3-slim-bullseye as base
FROM python:3.9-slim-bullseye as base
FROM base as builder
@@ -8,7 +8,7 @@ RUN apt-get update && apt-get -y install build-essential libssl-dev libffi-dev p
mkdir /install
WORKDIR /install
COPY requirements.txt .
RUN python -m pip install --prefix=/install --no-cache-dir --upgrade pip && \
RUN python -m pip install --no-cache-dir --upgrade pip && \
pip install --prefix=/install --no-cache-dir -r requirements.txt && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean
@@ -19,7 +19,10 @@ COPY --from=builder /install /usr/local
COPY app /app
WORKDIR /app
RUN apt-get update && \
apt-get -y install iputils-ping nmap && \
apt-get -y install iputils-ping nmap curl && \
rm -rf /var/lib/apt/lists/*
HEALTHCHECK --interval=10s \
CMD curl -fs "http://localhost:$DJANGO_PORT/health/" || exit 1
CMD ["./run.sh"]
+1 -1
View File
@@ -142,4 +142,4 @@ STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
VERSION = "v1.0.2"
VERSION = "v1.0.5"
+10
View File
@@ -17,6 +17,16 @@ if [ -n "$ENABLE_NOTIFICATIONS" ]; then
python -u manage.py shell -c "from wol.models import Settings; Settings.objects.update_or_create(id=1, defaults={'enable_notifications': '$ENABLE_NOTIFICATIONS'})"
fi
# set ping interval
if [ -z "$PING_INTERVAL" ]; then
PING_INTERVAL=5
elif [ "$PING_INTERVAL" -lt 5 ]; then
echo ""
echo "Ping interval lower than 5 seconds is not recommended. Please use an interval of 5 seconds or higher. Automatically set to 5 seconds."
echo ""
PING_INTERVAL=5
fi
celery -A django_wol worker &
celery -A django_wol beat &
gunicorn --bind 0.0.0.0:"$DJANGO_PORT" --workers 4 django_wol.asgi:application -k uvicorn.workers.UvicornWorker
+6 -6
View File
@@ -51,7 +51,7 @@
<form action="/settings/save/" method="post">
{% csrf_token %}
<div class="box no-flex">
<h2 class="title is-size-3 mb-4">General</h2>
<h2 class="title is-size-3 mb-5">General</h2>
<div class="columns">
<div class="column is-one-quarter">
<span class="mr-2"><strong>Notifications:</strong></span>
@@ -119,7 +119,7 @@
<div class="columns is-multiline is-mobile">
<div class="column is-full-mobile is-full-tablet is-full-desktop is-full-widescreen is-half-fullhd">
<div class="box no-flex">
<h2 class="title is-size-3 mb-4">Add custom device</h2>
<h2 class="title is-size-3 mb-5">Add custom device</h2>
<form action="/settings/custom_add/" method="post">
{% csrf_token %}
<table class="table is-fullwidth">
@@ -139,7 +139,7 @@
</tbody>
</table>
</form>
<h2 class="title is-size-3 mb-4">Scan for devices</h2>
<h2 class="title is-size-3 my-5">Scan for devices</h2>
{% if settings.scan_address %}
<button id="scan-button" class="button is-primary">Scan network</button>
{% else %}
@@ -165,7 +165,7 @@
</div>
<div class="column is-full-mobile is-full-tablet is-full-desktop is-full-widescreen is-half-fullhd">
<div class="box no-flex">
<h2 class="title is-size-3 mb-4">Delete devices</h2>
<h2 class="title is-size-3 mb-5">Delete devices</h2>
<div id="delete-table-container" class="table-container py-3">
<table id="delete-table" class="table is-fullwidth">
<thead>
@@ -194,7 +194,7 @@
<div class="columns">
<div class="column">
<div class="box">
<h2 class="title is-size-3 mb-4">App info</h2>
<h2 class="title is-size-3 mb-5">App info</h2>
<div class="columns is-mobile">
<div class="column">
<span class="mr-2"><strong>App version:</strong></span>
@@ -239,7 +239,7 @@
</div>
<div class="column">
<div class="box">
<h2 class="title is-size-3 mb-4">System info</h2>
<h2 class="title is-size-3 mb-5">System info</h2>
<div class="columns is-mobile">
<div class="column">
<span class="mr-2"><strong>System:</strong></span>
+2 -1
View File
@@ -9,5 +9,6 @@ urlpatterns = [
path("settings/scan/", views.settings_scan, name="settings_scan"),
path("settings/scan_add/", views.settings_scan_add, name="settings_scan_add"),
path("settings/custom_add/", views.settings_custom_add, name="settings_custom_add"),
path("settings/del/", views.settings_del, name="settings_del")
path("settings/del/", views.settings_del, name="settings_del"),
path("health/", views.health, name="health")
]
+8 -1
View File
@@ -6,7 +6,7 @@ import subprocess
from asgiref.sync import async_to_sync
from channels.layers import get_channel_layer
from django.http import HttpResponseRedirect
from django.http.response import JsonResponse
from django.http.response import HttpResponse, HttpResponseServerError, JsonResponse
from django.shortcuts import render
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
@@ -164,3 +164,10 @@ def settings_del(request):
})})
return JsonResponse(data=data)
def health(request):
try:
Settings.objects.all()
return HttpResponse("Ok")
except Exception:
return HttpResponseServerError("db: cannot connect to database.")
+12 -6
View File
@@ -4,10 +4,7 @@ services:
container_name: upsnap_django
image: seriousm4x/upsnap:latest
network_mode: host
depends_on:
- upsnap_redis
- upsnap_postgres
restart: always
restart: unless-stopped
environment:
- DJANGO_SUPERUSER_USER=admin
- DJANGO_SUPERUSER_PASSWORD=admin
@@ -21,20 +18,29 @@ services:
- POSTGRES_PASSWORD=upsnap
- PING_INTERVAL=5
- ENABLE_NOTIFICATIONS=True
depends_on:
- upsnap_redis
- upsnap_postgres
upsnap_redis:
container_name: upsnap_redis
image: redis:6
network_mode: host
restart: always
restart: unless-stopped
healthcheck:
test: redis-cli ping
interval: 10s
upsnap_postgres:
container_name: upsnap_postgres
image: postgres:13-alpine
restart: always
network_mode: host
restart: unless-stopped
environment:
- "POSTGRES_USER=upsnap"
- "POSTGRES_PASSWORD=upsnap"
- "POSTGRES_DB=upsnap"
healthcheck:
test: pg_isready -U $POSTGRES_USER
interval: 10s
volumes:
- upsnap_db:/var/lib/postgresql/data
volumes: