fix waitress

This commit is contained in:
Mateusz Gruszczyński 2025-03-04 11:44:11 +01:00
parent a7b3935e3b
commit 60e0762337

8
app.py
View File

@ -177,21 +177,21 @@ def automated_backups():
hosts = Host.query.all()
now = datetime.now(timezone.utc)
for host in hosts:
# Pobieramy ustawienia użytkownika
settings = UserSettings.query.filter_by(user_id=host.user_id).first()
backup_interval = settings.backup_interval if settings and settings.backup_interval else 60
# Pobieramy ostatni backup dla danego hosta
last_backup = Backup.query.filter_by(user_id=host.user_id, host_id=host.id).order_by(Backup.created_at.desc()).first()
if last_backup:
last_backup_time = last_backup.created_at
if last_backup_time.tzinfo is None:
last_backup_time = last_backup_time.replace(tzinfo=timezone.utc)
else:
last_backup_time = None
# Jeśli brak backupu lub minęło wystarczająco czasu, wykonujemy backup
if (last_backup_time is None) or ((now - last_backup_time).total_seconds() >= backup_interval * 60):
automated_backup_for_host(host)
def wrap_content_with_comments(content):
now_str = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC")
header_comment = f"# Auto-hosts upload: {now_str}\n"
@ -1127,7 +1127,7 @@ def scheduled_deployments():
deploy_user(setting.user_id)
setting.last_deploy_time = now
db.session.commit()
scheduler = BackgroundScheduler(timezone="UTC")
scheduler.add_job(func=scheduled_deployments, trigger="interval", minutes=5, next_run_time=datetime.now())
scheduler.add_job(func=automated_backups, trigger="interval", minutes=5, next_run_time=datetime.now())