fix cron on start, move from nicorn to waitress
This commit is contained in:
parent
972e7c61cd
commit
8dd96a68f2
41
app.py
41
app.py
@ -1390,6 +1390,47 @@ def delete_old_logs():
|
|||||||
flash(f"Usunięto {deleted_count} logów starszych niż {delete_days} dni.")
|
flash(f"Usunięto {deleted_count} logów starszych niż {delete_days} dni.")
|
||||||
return redirect(url_for('logs_page'))
|
return redirect(url_for('logs_page'))
|
||||||
|
|
||||||
|
@app.route('/test_email', methods=['POST'])
|
||||||
|
@login_required
|
||||||
|
def test_email():
|
||||||
|
s = get_settings()
|
||||||
|
# Sprawdzamy, czy ustawienia SMTP są skonfigurowane
|
||||||
|
if not (s.smtp_host and s.smtp_login and s.smtp_password):
|
||||||
|
flash("Brak skonfigurowanych ustawień SMTP.")
|
||||||
|
return redirect(url_for('settings_view'))
|
||||||
|
subject = "Testowy e-mail z RouterOS Backup"
|
||||||
|
body = "To jest testowa wiadomość e-mail wysłana z systemu RouterOS Backup."
|
||||||
|
success = send_mail_with_attachment(
|
||||||
|
smtp_host=s.smtp_host,
|
||||||
|
smtp_port=s.smtp_port,
|
||||||
|
smtp_user=s.smtp_login,
|
||||||
|
smtp_pass=s.smtp_password,
|
||||||
|
to_address=s.smtp_login,
|
||||||
|
subject=subject,
|
||||||
|
plain_body=body
|
||||||
|
)
|
||||||
|
if success:
|
||||||
|
flash("Testowy e-mail został wysłany.")
|
||||||
|
else:
|
||||||
|
flash("Wysyłka testowego e-maila nie powiodła się.")
|
||||||
|
return redirect(url_for('settings_view'))
|
||||||
|
|
||||||
|
@app.route('/test_pushover', methods=['POST'])
|
||||||
|
@login_required
|
||||||
|
def test_pushover():
|
||||||
|
s = get_settings()
|
||||||
|
# Sprawdzamy, czy ustawienia Pushover są skonfigurowane
|
||||||
|
if not (s.pushover_token and s.pushover_userkey):
|
||||||
|
flash("Brak skonfigurowanych ustawień Pushover.")
|
||||||
|
return redirect(url_for('settings_view'))
|
||||||
|
message = "Testowe powiadomienie Pushover z systemu RouterOS Backup."
|
||||||
|
success = send_pushover(s.pushover_token, s.pushover_userkey, message)
|
||||||
|
if success:
|
||||||
|
flash("Testowe powiadomienie Pushover zostało wysłane.")
|
||||||
|
else:
|
||||||
|
flash("Wysyłka testowego powiadomienia Pushover nie powiodła się.")
|
||||||
|
return redirect(url_for('settings_view'))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
reschedule_jobs()
|
reschedule_jobs()
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
bind = "0.0.0.0:81"
|
|
||||||
workers = 4
|
|
||||||
timeout = 120
|
|
||||||
server_header = False
|
|
||||||
def on_starting(server):
|
|
||||||
server.cfg.server_header = False
|
|
||||||
server.log.info("Server header disabled")
|
|
@ -3,10 +3,10 @@ Description=RouterOS Backup Waitress Service
|
|||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=routeros
|
#User=routeros
|
||||||
Group=routeros
|
#Group=routeros
|
||||||
WorkingDirectory=/opt/routeros_backup
|
WorkingDirectory=/opt/routeros_backup
|
||||||
ExecStart=/opt/routeros_backup/venv/bin/python3 run_waitress.py
|
ExecStart=/opt/routeros_backup/venv/bin/python3 /opt/routeros_backup/run_waitress.py
|
||||||
Restart=always
|
Restart=always
|
||||||
Environment=PYTHONUNBUFFERED=1
|
Environment=PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
@ -63,6 +63,15 @@
|
|||||||
<button type="submit" class="btn btn-primary btn-lg">Zapisz ustawienia</button>
|
<button type="submit" class="btn btn-primary btn-lg">Zapisz ustawienia</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<!-- Przycisk do testowania powiadomień -->
|
||||||
|
<div class="mt-4 text-center">
|
||||||
|
<form method="POST" action="{{ url_for('test_email') }}" class="d-inline">
|
||||||
|
<button type="submit" class="btn btn-info">Testuj wysyłkę e-mail</button>
|
||||||
|
</form>
|
||||||
|
<form method="POST" action="{{ url_for('test_pushover') }}" class="d-inline ms-2">
|
||||||
|
<button type="submit" class="btn btn-warning">Testuj powiadomienie Pushover</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer text-center">
|
<div class="card-footer text-center">
|
||||||
<p>Ustawienia dotyczące backupu oraz harmonogramu CRON znajdują się na <a href="{{ url_for('advanced_schedule') }}">zaawansowanych ustawieniach harmonogramu</a>.</p>
|
<p>Ustawienia dotyczące backupu oraz harmonogramu CRON znajdują się na <a href="{{ url_for('advanced_schedule') }}">zaawansowanych ustawieniach harmonogramu</a>.</p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user