Timezone configuration, cron monitoring and backup debug information

This commit is contained in:
Eduardo Silva 2024-04-05 22:11:08 -03:00
parent c5307ee1ee
commit 0714eff28a
9 changed files with 97 additions and 8 deletions

View file

@ -49,8 +49,9 @@ cd routerfleet
Use the following command to start your RouterFleet server. This command will also build the Docker image if it's the first time you're running it, or if there have been changes to the Dockerfile: Use the following command to start your RouterFleet server. This command will also build the Docker image if it's the first time you're running it, or if there have been changes to the Dockerfile:
```bash ```bash
SERVER_ADDRESS=yourserver.example.com POSTGRES_PASSWORD=your_password docker compose up --build -d SERVER_ADDRESS=yourserver.example.com POSTGRES_PASSWORD=your_password TIMEZONE=America/Sao_Paulo docker compose up --build -d
``` ```
[Timezone List](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
During the deployment, a self-signed certificate will be automatically generated for use with HTTPS. If you prefer to use your own certificates, proceed to the next step. During the deployment, a self-signed certificate will be automatically generated for use with HTTPS. If you prefer to use your own certificates, proceed to the next step.
@ -104,7 +105,7 @@ To maintain security, performance, and access to new features in RouterFleet, it
With the latest updates in place, re-deploy RouterFleet using Docker Compose. This step rebuilds the Docker image to incorporate any changes: With the latest updates in place, re-deploy RouterFleet using Docker Compose. This step rebuilds the Docker image to incorporate any changes:
```bash ```bash
SERVER_ADDRESS=yourserver.example.com POSTGRES_PASSWORD=your_password docker compose up --build -d SERVER_ADDRESS=yourserver.example.com POSTGRES_PASSWORD=your_password TIMEZONE=America/Sao_Paulo docker compose up --build -d
``` ```
6.**Verify Operation:** 6.**Verify Operation:**

View file

@ -3,6 +3,7 @@ from django.http import JsonResponse, HttpResponse, FileResponse
from django.shortcuts import render, get_object_or_404, redirect, Http404 from django.shortcuts import render, get_object_or_404, redirect, Http404
from django.contrib import messages from django.contrib import messages
from routerfleet_tools.models import WebadminSettings
from routerlib.backup_functions import perform_backup from routerlib.backup_functions import perform_backup
from .models import BackupProfile from .models import BackupProfile
from .forms import BackupProfileForm from .forms import BackupProfileForm
@ -98,10 +99,12 @@ def view_backup_details(request):
if backup_item.backup_text_hash and backup_item.backup_text_hash not in hash_list: if backup_item.backup_text_hash and backup_item.backup_text_hash not in hash_list:
hash_list.append(backup_item.backup_text_hash) hash_list.append(backup_item.backup_text_hash)
backup_list.append(backup_item) backup_list.append(backup_item)
webadmin_settings, _ = WebadminSettings.objects.get_or_create(name='webadmin_settings')
context = { context = {
'backup': backup, 'backup': backup,
'backup_list': backup_list, 'backup_list': backup_list,
'page_title': 'Backup Details' 'page_title': 'Backup Details',
'webadmin_settings': webadmin_settings
} }
return render(request, 'backup/backup_details.html', context) return render(request, 'backup/backup_details.html', context)

View file

@ -19,6 +19,7 @@ services:
- SERVER_ADDRESS=${SERVER_ADDRESS} - SERVER_ADDRESS=${SERVER_ADDRESS}
- DEBUG_MODE=${DEBUG_MODE} - DEBUG_MODE=${DEBUG_MODE}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- TIMEZONE=${TIMEZONE}
volumes: volumes:
- media_root:/var/lib/routerfleet/ - media_root:/var/lib/routerfleet/

View file

@ -34,6 +34,10 @@ DATABASES = {
} }
EOL EOL
if [ -n "$TIMEZONE" ]; then
echo "TIME_ZONE = '$TIMEZONE'" >> /app/routerfleet/production_settings.py
fi
sed -i "/^ path('admin\/', admin.site.urls),/s/^ / # /" /app/routerfleet/urls.py sed -i "/^ path('admin\/', admin.site.urls),/s/^ / # /" /app/routerfleet/urls.py
exec "$@" exec "$@"

View file

@ -140,6 +140,6 @@ STATICFILES_DIRS = [
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
MEDIA_ROOT = '/var/lib/routerfleet/' MEDIA_ROOT = '/var/lib/routerfleet/'
ROUTERFLEET_VERSION = 7002 ROUTERFLEET_VERSION = 7003
from routerfleet.production_settings import * from routerfleet.production_settings import *

View file

@ -0,0 +1,18 @@
# Generated by Django 5.0.3 on 2024-04-06 00:50
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('routerfleet_tools', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='webadminsettings',
name='cron_last_run',
field=models.DateTimeField(blank=True, null=True),
),
]

View file

@ -1,12 +1,14 @@
from django.db import models from django.db import models
import uuid import uuid
class WebadminSettings(models.Model): class WebadminSettings(models.Model):
name = models.CharField(default='webadmin_settings', max_length=20, unique=True) name = models.CharField(default='webadmin_settings', max_length=20, unique=True)
update_available = models.BooleanField(default=False) update_available = models.BooleanField(default=False)
current_version = models.PositiveIntegerField(default=0) current_version = models.PositiveIntegerField(default=0)
latest_version = models.PositiveIntegerField(default=0) latest_version = models.PositiveIntegerField(default=0)
last_checked = models.DateTimeField(blank=True, null=True) last_checked = models.DateTimeField(blank=True, null=True)
cron_last_run = models.DateTimeField(blank=True, null=True)
updated = models.DateTimeField(auto_now=True) updated = models.DateTimeField(auto_now=True)
created = models.DateTimeField(auto_now_add=True) created = models.DateTimeField(auto_now_add=True)

View file

@ -8,6 +8,8 @@ import requests
def cron_check_updates(request): def cron_check_updates(request):
webadmin_settings, webadmin_settings_created = WebadminSettings.objects.get_or_create(name='webadmin_settings') webadmin_settings, webadmin_settings_created = WebadminSettings.objects.get_or_create(name='webadmin_settings')
webadmin_settings.cron_last_run = timezone.now()
webadmin_settings.save()
if webadmin_settings.last_checked is None or timezone.now() - webadmin_settings.last_checked > timezone.timedelta( if webadmin_settings.last_checked is None or timezone.now() - webadmin_settings.last_checked > timezone.timedelta(
hours=1): hours=1):

View file

@ -37,6 +37,64 @@
{{ backup.id }} {{ backup.id }}
</span> </span>
</li> </li>
{% if not backup.success and not backup.error %}
<li class="list-group-item">
<b><i class="far fa-question-circle" title="This debug information is only displayed while the backup is not finished."></i> Backup Status</b>
<span class="float-right">
{% if backup.success %}
<i class="far fa-check-circle text-success"></i>
{% elif backup.error %}
<i class="far fa-times-circle text-danger"
title="{{ backup.error_message }}"></i>
{% elif backup.backup_pending_retrieval %}
<i class="fas fa-cloud-download-alt text-info"
title="Backup pending Retrieval"></i>
{% else %}
<i class="far fa-clock text-warning"></i>
{% endif %}
</span>
</li>
<li class="list-group-item">
<b><i class="far fa-question-circle" title="This debug information is only displayed while the backup is not finished."></i> Host Monitoring</b>
<span class="float-right">
{% if backup.router.monitoring %}
{% if backup.router.routerstatus.status_online %}
<i class="far fa-check-circle text-success"></i>
{% else %}
<i class="far fa-times-circle text-danger"></i> Host offline. Waiting for it to come online
{% endif %}
{% else %}
Not enabled
{% endif %}
</span>
</li>
<li class="list-group-item">
<b><i class="far fa-question-circle" title="This debug information is only displayed while the backup is not finished."></i> Retry Count</b>
<span class="float-right">
{{ backup.retry_count }}
</span>
</li>
<li class="list-group-item">
<b><i class="far fa-question-circle" title="This debug information is only displayed while the backup is not finished."></i> Next Retry</b>
<span class="float-right">
{{ backup.next_retry|default_if_none:"" }}
</span>
</li>
<li class="list-group-item">
<b><i class="far fa-question-circle" title="This debug information is only displayed while the backup is not finished."></i> Cron last run</b>
<span class="float-right">
{{ webadmin_settings.cron_last_run }}
</span>
</li>
{% endif %}
<li class="list-group-item"> <li class="list-group-item">
<b>Schedule Type</b> <b>Schedule Type</b>
<span class="float-right"> <span class="float-right">
@ -54,7 +112,7 @@
<li class="list-group-item"> <li class="list-group-item">
<b>Finish Time</b> <b>Finish Time</b>
<span class="float-right">{{ backup.finish_time }}</span> <span class="float-right">{{ backup.finish_time|default_if_none:"" }}</span>
</li> </li>
<li class="list-group-item"> <li class="list-group-item">
@ -94,6 +152,8 @@
</span> </span>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
@ -158,9 +218,7 @@
<div class="card-body row"> <div class="card-body row">
<div class="col-lg-12"> <div class="col-lg-12">
<pre>{{ backup.backup_text }}</pre> <pre>{{ backup.backup_text|default_if_none:"" }}</pre>
</div> </div>
</div> </div>
</div> </div>