Skip to content

Commit

Permalink
added logging app as submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
leoBitto committed Mar 2, 2024
1 parent 47afc51 commit a23105e
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 31 deletions.
70 changes: 70 additions & 0 deletions manager.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

# Questa funzione elimina le immagini precedenti e avvia i container
build_and_start_containers() {
# Stop tutti i container, incluso i volumi e quelli orfani
sudo docker-compose down -v --remove-orphans

# Avvia i container Docker in background e ricrea le immagini se necessario
sudo docker-compose -f docker-compose.yml up -d --build
echo "Immagini create"

# Applica le migrazioni del database all'interno del container "web"
sudo docker-compose -f docker-compose.yml exec web python manage.py migrate --noinput
echo "Migrazioni eseguite"

# Raccoglie i file statici all'interno del container "web", cancellando quelli esistenti
sudo docker-compose -f docker-compose.yml exec web python manage.py collectstatic --noinput --clear
echo "File statici raccolti"

# Crea un superuser con le credenziali dalle variabili d'ambiente
sudo docker-compose -f docker-compose.yml exec web python manage.py createsuperuser

echo "Superuser creato"
echo "Server in esecuzione"
}

# Questa funzione avvia solo i container Docker
start_containers() {
# Stop tutti i container, incluso i volumi e quelli orfani
sudo docker-compose down -v --remove-orphans

# Avvia i container Docker in background
sudo docker-compose -f docker-compose.yml up -d
echo "Immagini create"

# Applica le migrazioni del database all'interno del container "web"
sudo docker-compose -f docker-compose.yml exec web python manage.py migrate --noinput
echo "Migrazioni eseguite"

# Raccoglie i file statici all'interno del container "web", cancellando quelli esistenti
sudo docker-compose -f docker-compose.yml exec web python manage.py collectstatic --noinput --clear
echo "File statici raccolti"

echo "Server in esecuzione"
}

# Questa funzione ferma i container Docker
stop_containers() {
# Ferma tutti i container precedenti
sudo docker-compose down -v --remove-orphans

echo "Server fermato"
}

# Controlla gli argomenti passati allo script
case "$1" in
build)
build_and_start_containers
;;
start)
start_containers
;;
stop)
stop_containers
;;
*)
echo "Utilizzo: $0 {build|start|stop}"
exit 1
;;
esac
2 changes: 1 addition & 1 deletion src/base/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',

'logging_app.middleware.LogMiddleware',
]

ROOT_URLCONF = 'base.urls'
Expand Down
1 change: 1 addition & 0 deletions src/base/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
urlpatterns = [
path('admin/', admin.site.urls),
path('accounts/', include('django.contrib.auth.urls')),
path('dashboard/logging/', include('logging_app.urls', namespace='logging')),
path('', include('website.urls', namespace='website')),
]
if settings.DEBUG:
Expand Down
2 changes: 1 addition & 1 deletion src/logging_app
23 changes: 0 additions & 23 deletions start.sh

This file was deleted.

6 changes: 0 additions & 6 deletions stop.sh

This file was deleted.

0 comments on commit a23105e

Please sign in to comment.