diff --git a/README.md b/README.md index 7df65f2..258da8b 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,13 @@ ou sudo supervisorctl start|stop|restart reductstore sudo supervisorctl start|stop|restart test_tube:* +Ajouter scanner.local au fichier hosts des clients web: +192.168.1.xxx scanner.local +- linux : /etc/hosts" +- windows: C:\Windows\System32\drivers\etc\hosts" +- mac : /private/etc/hosts" + + ``` --- diff --git a/etc/5-install_adminer.sh b/etc/5-install_adminer.sh index d6f7be5..d71196e 100755 --- a/etc/5-install_adminer.sh +++ b/etc/5-install_adminer.sh @@ -1,5 +1,7 @@ #!/bin/bash +ETC="$(pwd)" + # Script d'installation d'Adminer avec Nginx (sans Apache) + détection automatique de PHP # Mise à jour des paquets echo "[1/6] Mise à jour des paquets..." @@ -30,32 +32,16 @@ ADMINER_VERSION=$(curl -s https://api.github.com/repos/vrana/adminer/releases/la sudo mkdir -p /var/www/adminer sudo wget "https://github.com/vrana/adminer/releases/download/v$ADMINER_VERSION/adminer-$ADMINER_VERSION.php" -O /var/www/adminer/index.php + # Configuration de Nginx pour Adminer echo "[4/6] Configuration de Nginx..." -sudo bash -c " -cat > /etc/nginx/sites-available/adminer <<'END' -server { - listen 81; - server_name scanner.local; +sudo usermod -aG www-data rpi4 +sudo ln -s $ETC/nginx_service.conf /etc/nginx/sites-enabled/ - root /var/www/adminer; - index index.php; - - location / { - try_files \$uri \$uri/ =404; - } - - location ~ \.php$ { - include snippets/fastcgi-php.conf; - fastcgi_pass unix:/var/run/php/php${PHP_VERSION}-fpm.sock; - fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; - include fastcgi_params; - } -} -END" +sudo chown -R www-data:www-data /var/www/adminer/ +sudo chmod -R 755 /var/www/adminer/ # Activation du site Nginx -sudo ln -s /etc/nginx/sites-available/adminer /etc/nginx/sites-enabled/ sudo nginx -t # Teste la configuration Nginx # Redémarrage des services @@ -77,6 +63,7 @@ echo "Version de PHP utilisée : $PHP_VERSION" echo "Ajouter 'scanner.local' au fichier hosts:" echo " linux : /etc/hosts" echo " windows: C:\Windows\System32\drivers\etc\hosts" +echo " mac: /private/etc/hosts" echo "" echo "Pour accéder à Adminer depuis cette machine:" echo " http://scanner.local:81" diff --git a/etc/nginx_service.conf b/etc/nginx_service.conf new file mode 100644 index 0000000..420cf4c --- /dev/null +++ b/etc/nginx_service.conf @@ -0,0 +1,65 @@ +# nginx.conf + +server { + listen 80; + server_name scanner.local; + + keepalive_timeout 5; + client_max_body_size 4G; + + # ---- Static + location /static/ { + alias /home/rpi4/PlanarianScanner/test_tube_scanner/staticfiles/; + expires 30d; + access_log off; + } + location /favicon.ico { + alias /home/rpi4/PlanarianScanner/test_tube_scanner/staticfiles/img/logo.png; + } + + # ---- Media + location /media/ { + alias /home/rpi4/PlanarianScanner/test_tube_scanner/media/; + expires 30d; + access_log off; + } + + # ---- WebSocket + location /ws/ { + proxy_pass http://127.0.0.1:8000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_read_timeout 86400; # Temps de timeout long pour les WebSockets + } + + # ---- Django HTTP + location / { + proxy_pass http://127.0.0.1:8000; # Port par défaut de Daphne + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /adminer/ { + alias /var/www/adminer/; + index index.php; + + location ~ \.php$ { + include snippets/fastcgi-php.conf; + fastcgi_pass unix:/var/run/php/php8.4-fpm.sock; + fastcgi_param SCRIPT_FILENAME $request_filename; + include fastcgi_params; + } + } +} + + diff --git a/etc/scanner_service.conf b/etc/scanner_service.conf index cdae740..ba2b615 100644 --- a/etc/scanner_service.conf +++ b/etc/scanner_service.conf @@ -35,7 +35,7 @@ redirect_stderr=true process_name=%(program_name)s priority=900 directory=/home/rpi4/PlanarianScanner/test_tube_scanner -command=/home/rpi4/PlanarianScanner/run-workers.sh +command=/home/rpi4/PlanarianScanner/test_tube_scanner/run-workers.sh user=rpi4 group=rpi4 stopasgroup=true diff --git a/run-workers.sh b/run-workers.sh deleted file mode 100755 index beda0d8..0000000 --- a/run-workers.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -APP_DIR="/home/rpi4/PlanarianScanner" -cd "$APP_DIR/test_tube_scanner" - -echo "start workers" -$APP_DIR/.venv/bin/python manage.py start_workers - -echo "start celery" -$APP_DIR/.venv/bin/celery -A home worker -l info diff --git a/test_tube_scanner/home/settings.py b/test_tube_scanner/home/settings.py index 9047200..51df51d 100644 --- a/test_tube_scanner/home/settings.py +++ b/test_tube_scanner/home/settings.py @@ -20,7 +20,7 @@ print("Django BASE_DIR:", BASE_DIR) PACKAGE_DIR = BASE_DIR.parent APP_DATAS = PACKAGE_DIR / config('APP_DATAS') -print("Django application data:", APP_DATAS) + # Quick-start development settings - unsuitable for production @@ -215,9 +215,13 @@ LOCALE_PATHS = ( STATIC_URL = '/static/' STATIC_ROOT = APP_DATAS / 'staticfiles' +print("Django application STATIC_ROOT:", STATIC_ROOT) + MEDIA_URL = '/media/' MEDIA_ROOT = APP_DATAS / 'media' +print("Django application MEDIA_ROOT:", MEDIA_ROOT) + """ STATICFILES_DIRS = [ @@ -259,7 +263,7 @@ LOGGING = None if not IS_LOGGING else { "encoding" : "utf-8", }, 'file': { - 'level': 'INFO', + 'level': 'DEBUG', 'class':'logging.handlers.RotatingFileHandler', 'filename': BASE_DIR / "logs" / LOGGING_FILE, 'maxBytes': 1024*1024*15, # 15MB @@ -270,9 +274,9 @@ LOGGING = None if not IS_LOGGING else { 'console': {'class': 'logging.StreamHandler',}, }, 'loggers': { - "django": {"handlers": ["null"], "level": "ERROR", "propagate": False,}, - "uvicorn": {"handlers": ["null"], "level": "ERROR", "propagate": False,}, - "daphne": {"handlers": ["null"], "level": "ERROR", "propagate": False,}, + "django": {"handlers": ["file"], "level": "ERROR", "propagate": False,}, + "uvicorn": {"handlers": ["file"], "level": "ERROR", "propagate": False,}, + "daphne": {"handlers": ["file"], "level": "ERROR", "propagate": False,}, 'axes': {"handlers": ['file',],"level": "INFO", "propagate": True, }, "celery": {"handlers": ["celery_file"], "level": "INFO", "propagate": False,}, "celery.task": {"handlers": ["celery_file"], "level": "INFO", "propagate": False, }, diff --git a/test_tube_scanner/home/templates/inc/404.html b/test_tube_scanner/home/templates/inc/404.html index 58b1380..8ba1407 100644 --- a/test_tube_scanner/home/templates/inc/404.html +++ b/test_tube_scanner/home/templates/inc/404.html @@ -1,7 +1,7 @@ -{% extends 'dashboard/base.html' %} +{% extends 'layout.html' %} {% load i18n %} -{% block main_content %} +{% block content %}
{% trans "Base de données Reductstore" %}
-
+
{% trans "Base de données mariadb" %}
-
diff --git a/test_tube_scanner/scanner/urls.py b/test_tube_scanner/scanner/urls.py
index 76b40a7..6f81fd2 100644
--- a/test_tube_scanner/scanner/urls.py
+++ b/test_tube_scanner/scanner/urls.py
@@ -5,18 +5,18 @@ from . import views
app_name = "scanner"
urlpatterns = [
- path('scanner/admin/', views.admin_view, name='admin'),
- path('scanner/reductstore/', views.reductstore_view, name='reductstore'),
- path('scanner/adminer/', views.adminer_view, name='adminer'),
- path('scanner/portainer/', views.portainer_view, name='portainer'),
- path('scanner/calibration/', views.calibration_view, name='calibration'),
- path('scanner/supervisor/', views.supervisor_view, name='supervisor'),
- path('scanner/logs/worker', views.supervisor_worker, name='logs_worker'),
- path('scanner/logs/scheduler', views.supervisor_scheduler, name='logs_scheduler'),
+ path('admin/', views.admin_view, name='admin'),
+ path('reductstore/', views.reductstore_view, name='reductstore'),
+ path('adminer/', views.adminer_view, name='adminer'),
+ path('portainer/', views.portainer_view, name='portainer'),
+ path('calibration/', views.calibration_view, name='calibration'),
+ path('supervisor/', views.supervisor_view, name='supervisor'),
+ path('logs/worker', views.supervisor_worker, name='logs_worker'),
+ path('logs/scheduler', views.supervisor_scheduler, name='logs_scheduler'),
path('main/', views.main_view, name='main'),
- path('scanner/images/', views.images_view, name='images'),
- path('scanner/replay/', views.replay_view, name='replay'),
+ path('images/', views.images_view, name='images'),
+ path('replay/', views.replay_view, name='replay'),
path('api/stats/', views.stats_view, name='api_stats'),
path('api/video/', views.download_api, name='download_api'),
path('api/export/', views.export_api, name='export_api'),
diff --git a/test_tube_scanner/scanner/views.py b/test_tube_scanner/scanner/views.py
index fa8f20c..5edad37 100644
--- a/test_tube_scanner/scanner/views.py
+++ b/test_tube_scanner/scanner/views.py
@@ -54,7 +54,7 @@ def reductstore_view(request):
@login_required
def adminer_view(request):
- return render(request, "scanner/iframe.html", context=global_context(request, link=f'http://{settings.DOMAIN_SERVER}:81/'))
+ return render(request, "scanner/redirection.html", context=global_context(request, link=f'http://{settings.DOMAIN_SERVER}/adminer/'))
@login_required
def portainer_view(request):