# Path: runtime/config.py
# def rkt_path_d(path):
# def rkt_stage1_d(path):
# def dgr_config(path):
# def acserver_config(path):


import multiprocessing
import os.path
import signal
import subprocess
import sys
import requests
from runtime import (
    config,
)


RUNTIME_PATH = os.path.dirname(os.path.abspath(__file__))
PROJECT_PATH = os.path.dirname(RUNTIME_PATH)

sys.path.append(PROJECT_PATH)
sys.path.append(RUNTIME_PATH)

for p in os.listdir(os.path.join(PROJECT_PATH, "env/lib/")):
    PYTHON_LIB = os.path.join(PROJECT_PATH, "env/lib/%s/site-packages" % p)
    sys.path.append(PYTHON_LIB)



def start_acserver():
    cmd = ["%s/acserver/acserver" % RUNTIME_PATH, "%s/ac-config.yml" % RUNTIME_PATH]
    os.execve(cmd[0], cmd, os.environ)


class AcserverError(Exception):
    pass


if __name__ == '__main__':
    if os.geteuid() != 0:
        raise PermissionError("start as root")
    with open("/dev/null", 'w') as null:
        code = subprocess.call(["ip", "addr", "show", "rack0"], stdout=null)
        if code != 0:
            config.rkt_path_d(RUNTIME_PATH)

# Path: runtime/config.py
# def rkt_path_d(path):
# def rkt_stage1_d(path):
# def dgr_config(path):
# def acserver_config(path):


# Path: runtime/run_acserver.py
import multiprocessing
import os.path
import signal
import subprocess
import sys
import requests
from runtime import (
    config,
)



RUNTIME_PATH = os.path.dirname(os.path.abspath(__file__))
PROJECT_PATH = os.path.dirname(RUNTIME_PATH)

sys.path.append(PROJECT_PATH)
sys.path.append(RUNTIME_PATH)

for p in os.listdir(os.path.join(PROJECT_PATH, "env/lib/")):
    PYTHON_LIB = os.path.join(PROJECT_PATH, "env/lib/%s/site-packages" % p)
    sys.path.append(PYTHON_LIB)



def start_acserver():
    cmd = ["%s/acserver/acserver" % RUNTIME_PATH, "%s/ac-config.yml" % RUNTIME_PATH]
    os.execve(cmd[0], cmd, os.environ)


class AcserverError(Exception):
    pass


if __name__ == '__main__':
    if os.geteuid() != 0:
        raise PermissionError("start as root")
    with open("/dev/null", 'w') as null:
        code = subprocess.call(["ip", "addr", "show", "rack0"], stdout=null)
        if code != 0:
            config.rkt_path_d(RUNTIME_PATH)

            config.rkt_stage1_d(RUNTIME_PATH)