Features: 1) Add exit condition checks for $LASTEXITCODE in various PowerShell scripts to ensure graceful error handling; 2) Enhance schema filtering with additional condition for active vendors in graphene/schema.py;
Fixes: 1) Remove unused imports in `celery.py`; Extra: Refactor formatting and improve code readability in PowerShell scripts.
This commit is contained in:
parent
2eede833ef
commit
602a59bd84
8 changed files with 74 additions and 3 deletions
|
|
@ -145,7 +145,11 @@ class Query(ObjectType):
|
||||||
Product.objects.all().select_related("brand", "category").prefetch_related("images", "stocks")
|
Product.objects.all().select_related("brand", "category").prefetch_related("images", "stocks")
|
||||||
if info.context.user.has_perm("core.view_product")
|
if info.context.user.has_perm("core.view_product")
|
||||||
else Product.objects.filter(
|
else Product.objects.filter(
|
||||||
is_active=True, brand__is_active=True, category__is_active=True, stocks__isnull=False
|
is_active=True,
|
||||||
|
brand__is_active=True,
|
||||||
|
category__is_active=True,
|
||||||
|
stocks__isnull=False,
|
||||||
|
stocks__vendor__is_active=True,
|
||||||
)
|
)
|
||||||
.select_related("brand", "category")
|
.select_related("brand", "category")
|
||||||
.prefetch_related("images", "stocks")
|
.prefetch_related("images", "stocks")
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@ import os
|
||||||
|
|
||||||
from celery import Celery
|
from celery import Celery
|
||||||
|
|
||||||
from evibes.settings import REDIS_PASSWORD, TIME_ZONE
|
|
||||||
|
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "evibes.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "evibes.settings")
|
||||||
|
|
||||||
app = Celery("evibes")
|
app = Celery("evibes")
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,20 @@ Set-StrictMode -Version Latest
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
.\scripts\Windows\starter.ps1
|
.\scripts\Windows\starter.ps1
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
|
|
||||||
Write-Host "Starting database backup process..." -ForegroundColor Magenta
|
Write-Host "Starting database backup process..." -ForegroundColor Magenta
|
||||||
docker compose exec app poetry run python manage.py dbbackup
|
docker compose exec app poetry run python manage.py dbbackup
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
Write-Host "Database backup created under ./dbbackup" -ForegroundColor Green
|
Write-Host "Database backup created under ./dbbackup" -ForegroundColor Green
|
||||||
|
|
||||||
Write-Host "Starting media backup process..." -ForegroundColor Magenta
|
Write-Host "Starting media backup process..." -ForegroundColor Magenta
|
||||||
docker compose exec app poetry run python manage.py mediabackup
|
docker compose exec app poetry run python manage.py mediabackup
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
Write-Host "Media backup created under ./dbbackup" -ForegroundColor Green
|
Write-Host "Media backup created under ./dbbackup" -ForegroundColor Green
|
||||||
|
|
@ -3,6 +3,9 @@ Set-StrictMode -Version Latest
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
.\scripts\Windows\starter.ps1
|
.\scripts\Windows\starter.ps1
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
|
|
||||||
$envFile = '.env'
|
$envFile = '.env'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@ Set-StrictMode -Version Latest
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
.\scripts\Windows\starter.ps1
|
.\scripts\Windows\starter.ps1
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
|
|
||||||
function Get-RandomHex
|
function Get-RandomHex
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,30 +2,51 @@ Set-StrictMode -Version Latest
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
.\scripts\Windows\starter.ps1
|
.\scripts\Windows\starter.ps1
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Write-Host "Shutting down..." -ForegroundColor Magenta
|
Write-Host "Shutting down..." -ForegroundColor Magenta
|
||||||
docker compose down
|
docker compose down
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
Write-Host "Services were shut down successfully!" -ForegroundColor Green
|
Write-Host "Services were shut down successfully!" -ForegroundColor Green
|
||||||
|
|
||||||
Write-Host "Spinning services up..." -ForegroundColor Magenta
|
Write-Host "Spinning services up..." -ForegroundColor Magenta
|
||||||
docker compose up -d --build --wait
|
docker compose up -d --build --wait
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
Write-Host "Services are up and healthy!" -ForegroundColor Green
|
Write-Host "Services are up and healthy!" -ForegroundColor Green
|
||||||
|
|
||||||
Write-Host "Applying migrations..." -ForegroundColor Magenta
|
Write-Host "Applying migrations..." -ForegroundColor Magenta
|
||||||
docker compose exec app poetry run python manage.py migrate --no-input --verbosity 0
|
docker compose exec app poetry run python manage.py migrate --no-input --verbosity 0
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
Write-Host "Migrations applied successfully!" -ForegroundColor Green
|
Write-Host "Migrations applied successfully!" -ForegroundColor Green
|
||||||
|
|
||||||
Write-Host "Collecting static files..." -ForegroundColor Magenta
|
Write-Host "Collecting static files..." -ForegroundColor Magenta
|
||||||
docker compose exec app poetry run python manage.py collectstatic --clear --no-input --verbosity 0
|
docker compose exec app poetry run python manage.py collectstatic --clear --no-input --verbosity 0
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
Write-Host "Static files collected successfully!" -ForegroundColor Green
|
Write-Host "Static files collected successfully!" -ForegroundColor Green
|
||||||
|
|
||||||
Write-Host "Setting default caches..." -ForegroundColor Magenta
|
Write-Host "Setting default caches..." -ForegroundColor Magenta
|
||||||
docker compose exec app poetry run python manage.py set_default_caches
|
docker compose exec app poetry run python manage.py set_default_caches
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
Write-Host "Default caches set successfully!" -ForegroundColor Green
|
Write-Host "Default caches set successfully!" -ForegroundColor Green
|
||||||
|
|
||||||
Write-Host "Cleaning up unused Docker data..." -ForegroundColor Magenta
|
Write-Host "Cleaning up unused Docker data..." -ForegroundColor Magenta
|
||||||
docker system prune -f
|
docker system prune -f
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
Write-Host "Unused Docker data cleaned successfully!" -ForegroundColor Green
|
Write-Host "Unused Docker data cleaned successfully!" -ForegroundColor Green
|
||||||
|
|
||||||
Write-Host "All done! eVibes is up and running!" -ForegroundColor Cyan
|
Write-Host "All done! eVibes is up and running!" -ForegroundColor Cyan
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@ Set-StrictMode -Version Latest
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
.\scripts\Windows\starter.ps1
|
.\scripts\Windows\starter.ps1
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
|
|
||||||
Write-Host "Verifying all images are present…" -ForegroundColor Green
|
Write-Host "Verifying all images are present…" -ForegroundColor Green
|
||||||
|
|
||||||
|
|
@ -29,22 +32,37 @@ foreach ($prop in $config.services.PSObject.Properties)
|
||||||
|
|
||||||
Write-Host "Spinning services up..." -ForegroundColor Magenta
|
Write-Host "Spinning services up..." -ForegroundColor Magenta
|
||||||
docker compose up --no-build --detach --wait
|
docker compose up --no-build --detach --wait
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
Write-Host "Services are up and healthy!" -ForegroundColor Green
|
Write-Host "Services are up and healthy!" -ForegroundColor Green
|
||||||
|
|
||||||
Write-Host "Applying migrations..." -ForegroundColor Magenta
|
Write-Host "Applying migrations..." -ForegroundColor Magenta
|
||||||
docker compose exec app poetry run python manage.py migrate --no-input
|
docker compose exec app poetry run python manage.py migrate --no-input
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
Write-Host "Migrations applied successfully!" -ForegroundColor Green
|
Write-Host "Migrations applied successfully!" -ForegroundColor Green
|
||||||
|
|
||||||
Write-Host "Collecting static files..." -ForegroundColor Magenta
|
Write-Host "Collecting static files..." -ForegroundColor Magenta
|
||||||
docker compose exec app poetry run python manage.py collectstatic --clear --no-input
|
docker compose exec app poetry run python manage.py collectstatic --clear --no-input
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
Write-Host "Static files collected successfully!" -ForegroundColor Green
|
Write-Host "Static files collected successfully!" -ForegroundColor Green
|
||||||
|
|
||||||
Write-Host "Setting default caches..." -ForegroundColor Magenta
|
Write-Host "Setting default caches..." -ForegroundColor Magenta
|
||||||
docker compose exec app poetry run python manage.py set_default_caches
|
docker compose exec app poetry run python manage.py set_default_caches
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
Write-Host "Default caches set successfully!" -ForegroundColor Green
|
Write-Host "Default caches set successfully!" -ForegroundColor Green
|
||||||
|
|
||||||
Write-Host "Cleaning unused Docker data..." -ForegroundColor Magenta
|
Write-Host "Cleaning unused Docker data..." -ForegroundColor Magenta
|
||||||
docker system prune -f
|
docker system prune -f
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
Write-Host "Unused Docker data cleaned successfully!" -ForegroundColor Green
|
Write-Host "Unused Docker data cleaned successfully!" -ForegroundColor Green
|
||||||
|
|
||||||
Write-Host "All done! eVibes is up and running!" -ForegroundColor Cyan
|
Write-Host "All done! eVibes is up and running!" -ForegroundColor Cyan
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,33 @@ Set-StrictMode -Version Latest
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
.\scripts\Windows\starter.ps1
|
.\scripts\Windows\starter.ps1
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
|
|
||||||
Write-Host "Shutting down..." -ForegroundColor Magenta
|
Write-Host "Shutting down..." -ForegroundColor Magenta
|
||||||
docker compose down
|
docker compose down
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
Write-Host "Services were shut down successfully!" -ForegroundColor Green
|
Write-Host "Services were shut down successfully!" -ForegroundColor Green
|
||||||
|
|
||||||
Write-Host "Removing volumes..." -ForegroundColor Magenta
|
Write-Host "Removing volumes..." -ForegroundColor Magenta
|
||||||
docker volume remove -f evibes_prometheus-data
|
docker volume remove -f evibes_prometheus-data
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
docker volume remove -f evibes_es-data
|
docker volume remove -f evibes_es-data
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
Write-Host "Volumes were removed successfully!" -ForegroundColor Green
|
Write-Host "Volumes were removed successfully!" -ForegroundColor Green
|
||||||
|
|
||||||
Write-Host "Cleaning up unused Docker data..." -ForegroundColor Magenta
|
Write-Host "Cleaning up unused Docker data..." -ForegroundColor Magenta
|
||||||
docker system prune -a -f --volumes
|
docker system prune -a -f --volumes
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
exit $LASTEXITCODE
|
||||||
|
}
|
||||||
Write-Host "Unused Docker data cleaned successfully!" -ForegroundColor Green
|
Write-Host "Unused Docker data cleaned successfully!" -ForegroundColor Green
|
||||||
|
|
||||||
Write-Host "Removing related files..." -ForegroundColor Magenta
|
Write-Host "Removing related files..." -ForegroundColor Magenta
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue