$91 GRAYBYTE WORDPRESS FILE MANAGER $18

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/cloudlinux/venv/lib/python3.11/site-packages/xray/console_utils/

HOME
Current File : /opt/cloudlinux/venv/lib/python3.11/site-packages/xray/console_utils//run_agent.py
# -*- coding: utf-8 -*-

# Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2021 All Rights Reserved
#
# Licensed under CLOUD LINUX LICENSE AGREEMENT
# http://cloudlinux.com/docs/LICENSE.TXT

"""
This module contains X Ray Agent main run function
"""
import os
from typing import Optional

from xray import gettext as _
from xray.agent.daemon import Agent
from xray.internal import constants
from xray.internal.utils import (
    configure_logging,
    create_socket,
    write_sys_id,
    read_sys_id
)


PIDFILE = '/var/run/xray-agent.pid'

def _save_pid(pid: int, pidfile: str):
    """
    Save agent process pid to file that other tools can use.
    """
    with open(pidfile, 'w') as f:
        f.write(str(pid))


def _read_pid(pidfile: str) -> Optional[int]:
    try:
        with open(pidfile, 'r') as f:
            pid = int(f.read())
    except (OSError, IOError, ValueError):
        return None

    # check that process is really still alive
    # and not just failed to clean the pidfile
    try:
        os.kill(pid, 0)
    except ProcessLookupError:
        return None

    return pid


def run(agent = None,
        pidfile: str = PIDFILE,
        system_id_cache_file: str = constants.agent_file) -> None:
    """
    Main run function
    """
    if _read_pid(pidfile):
        print(_('Another daemon instance is already running, please, stop it first.'))
        exit(1)

    configure_logging(constants.agent_log)

    if agent is None:
        agent = Agent(system_id=read_sys_id())

    write_sys_id(agent.sys_id, agent_system_id_path=system_id_cache_file)
    _save_pid(pid=os.getpid(), pidfile=pidfile)

    with create_socket(constants.agent_sock) as socket:
        agent.start(socket, background_routine=True)

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
16 Dec 2025 9.31 PM
root / root
0755
__pycache__
--
17 Dec 2025 2.54 AM
root / root
0755
run_user
--
16 Dec 2025 9.31 PM
root / root
0755
__init__.py
0 KB
20 Oct 2025 7.04 PM
root / root
0644
base_app.py
0.921 KB
20 Oct 2025 7.04 PM
root / root
0644
cmdline_parser.py
23.708 KB
20 Oct 2025 7.04 PM
root / root
0644
run_agent.py
1.715 KB
20 Oct 2025 7.04 PM
root / root
0644
run_continuous.py
0.618 KB
20 Oct 2025 7.04 PM
root / root
0644
run_manager.py
3.946 KB
20 Oct 2025 7.04 PM
root / root
0644
run_smart_advice.py
7.438 KB
20 Oct 2025 7.04 PM
root / root
0644
validations.py
10.066 KB
20 Oct 2025 7.04 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF