install final
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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, },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends 'dashboard/base.html' %}
|
||||
{% extends 'layout.html' %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block main_content %}
|
||||
{% block content %}
|
||||
<div class="w3-black w3-border w3-div-center" style="margin: 10em; height: 20em">
|
||||
{% block main-bar %}
|
||||
<div class="w3-orange">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends 'dashboard/base.html' %}
|
||||
{% extends 'layout.html' %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block main_content %}
|
||||
{% block content %}
|
||||
<div class="w3-black w3-border w3-div-center" style="margin: 10em; height: 20em">
|
||||
{% block main-bar %}
|
||||
<div class="w3-orange">
|
||||
|
||||
@@ -36,7 +36,7 @@ urlpatterns += i18n_patterns(
|
||||
path('login/', auth_views.LoginView.as_view(template_name='admin/login.html'), name='login'),
|
||||
path('logout/', auth_views.LogoutView.as_view(), name='logout'),
|
||||
|
||||
path('', RedirectView.as_view(url='/scanner/main/', permanent=True), name='redirect_to_mainboard'),
|
||||
path('', RedirectView.as_view(url='/scanner/calibration/', permanent=True), name='redirect_to_mainboard'),
|
||||
path('scanner/', include('scanner.urls', namespace='scanner')),
|
||||
)
|
||||
|
||||
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "start workers"
|
||||
../.venv/bin/python manage.py start_workers
|
||||
|
||||
echo "start celery"
|
||||
../.venv/bin/celery -A home worker -l info
|
||||
@@ -77,10 +77,10 @@
|
||||
<a href="{% url 'scanner:reductstore' %}" class="w3-bar-item w3-btn w3-hover-opacity w3-margin-left">
|
||||
<img class="w3-no-padding" src="/static/img/reductstore.png" style="width: 24px"> {% trans "Base de données Reductstore" %}
|
||||
</a>
|
||||
<a href="{% url 'scanner:adminer' %}" class="w3-bar-item w3-btn w3-hover-opacity w3-margin-left">
|
||||
<a href="{% url 'scanner:adminer' %}" class="w3-bar-item w3-btn w3-hover-opacity w3-margin-left" target="_blank">
|
||||
<img class="w3-no-padding" src="/static/img/adminer.png" style="width: 28px"> {% trans "Base de données mariadb" %}
|
||||
</a>
|
||||
<!--a href="{% url 'scanner:portainer' %}" class="w3-bar-item w3-btn w3-hover-opacity" w3-margin-left>
|
||||
<!--a href="{% url 'scanner:portainer' %}" class="w3-bar-item w3-btn w3-hover-opacity" w3-margin-left target="_blank">
|
||||
<img class="w3-no-padding" src="/static/img/portainer.png" style="width: 28px"> {% trans "Portainer" %}
|
||||
</a-->
|
||||
<a href="{% url 'scanner:supervisor' %}" class="w3-bar-item w3-btn w3-hover-opacity w3-margin-left">
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user