wip: make work Services Status
This commit is contained in:
+16
-5
@@ -35,12 +35,13 @@ class EmailManager(BaseServiceManager):
|
||||
is_docker = os.path.exists('/.dockerenv') or os.environ.get('DOCKER_CONTAINER') == 'true'
|
||||
|
||||
if is_docker:
|
||||
# Return positive status when running in Docker
|
||||
# Check if email container is actually running
|
||||
container_running = self._check_email_container_status()
|
||||
status = {
|
||||
'running': True,
|
||||
'status': 'online',
|
||||
'smtp_running': True,
|
||||
'imap_running': True,
|
||||
'running': container_running,
|
||||
'status': 'online' if container_running else 'offline',
|
||||
'smtp_running': container_running,
|
||||
'imap_running': container_running,
|
||||
'users_count': 0,
|
||||
'domain': 'cell.local',
|
||||
'timestamp': datetime.utcnow().isoformat()
|
||||
@@ -106,6 +107,16 @@ class EmailManager(BaseServiceManager):
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def _check_email_container_status(self) -> bool:
|
||||
"""Check if email Docker container is running"""
|
||||
try:
|
||||
import docker
|
||||
client = docker.from_env()
|
||||
containers = client.containers.list(filters={'name': 'cell-mail'})
|
||||
return len(containers) > 0
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def _test_smtp_connectivity(self) -> Dict[str, Any]:
|
||||
"""Test SMTP connectivity"""
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user