fix waitress
This commit is contained in:
parent
a7b3935e3b
commit
60e0762337
8
app.py
8
app.py
@ -177,21 +177,21 @@ def automated_backups():
|
|||||||
hosts = Host.query.all()
|
hosts = Host.query.all()
|
||||||
now = datetime.now(timezone.utc)
|
now = datetime.now(timezone.utc)
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
# Pobieramy ustawienia użytkownika
|
|
||||||
settings = UserSettings.query.filter_by(user_id=host.user_id).first()
|
settings = UserSettings.query.filter_by(user_id=host.user_id).first()
|
||||||
backup_interval = settings.backup_interval if settings and settings.backup_interval else 60
|
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()
|
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:
|
if last_backup:
|
||||||
last_backup_time = last_backup.created_at
|
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:
|
else:
|
||||||
last_backup_time = None
|
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):
|
if (last_backup_time is None) or ((now - last_backup_time).total_seconds() >= backup_interval * 60):
|
||||||
automated_backup_for_host(host)
|
automated_backup_for_host(host)
|
||||||
|
|
||||||
|
|
||||||
def wrap_content_with_comments(content):
|
def wrap_content_with_comments(content):
|
||||||
now_str = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC")
|
now_str = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC")
|
||||||
header_comment = f"# Auto-hosts upload: {now_str}\n"
|
header_comment = f"# Auto-hosts upload: {now_str}\n"
|
||||||
@ -1127,7 +1127,7 @@ def scheduled_deployments():
|
|||||||
deploy_user(setting.user_id)
|
deploy_user(setting.user_id)
|
||||||
setting.last_deploy_time = now
|
setting.last_deploy_time = now
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
scheduler = BackgroundScheduler(timezone="UTC")
|
scheduler = BackgroundScheduler(timezone="UTC")
|
||||||
scheduler.add_job(func=scheduled_deployments, trigger="interval", minutes=5, next_run_time=datetime.now())
|
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())
|
scheduler.add_job(func=automated_backups, trigger="interval", minutes=5, next_run_time=datetime.now())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user