Files
hostpanel/ssh_manager/apps.py
ilkeral 342f1314c7 yeni
2025-07-21 13:49:36 +03:00

24 lines
811 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from django.apps import AppConfig
from django.conf import settings
def check_server_connection():
from .ssh_client import SSHManager # utils yerine ssh_client'dan import et
from .models import SSHCredential
# Tüm SSH bağlantılarını kontrol et
for credential in SSHCredential.objects.all():
ssh_manager = SSHManager(credential)
is_online = ssh_manager.check_connection()
# Bağlantı durumunu güncelle
credential.is_online = is_online
credential.save(update_fields=['is_online', 'last_check'])
ssh_manager.close()
class SshManagerConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'ssh_manager'
def ready(self):
import ssh_manager.signals # signals'ı import et