v2xray init
This commit is contained in:
21
xray_run.py
Normal file
21
xray_run.py
Normal file
@@ -0,0 +1,21 @@
|
||||
'''
|
||||
To kill the process: ps -ef | grep python
|
||||
'''
|
||||
from os import path as _pth
|
||||
from time import sleep
|
||||
CURRENT_DIR = _pth.abspath(_pth.dirname(__file__))
|
||||
XRAY_PATH = _pth.join(CURRENT_DIR, "config", "xray")
|
||||
|
||||
def run():
|
||||
import os, xray_config, subprocess, signal
|
||||
os.chdir(xray_config.CONFIG_DIR)
|
||||
sleep(0.5)
|
||||
p = subprocess.Popen([XRAY_PATH, "-c", xray_config.CONFIG_FILE])
|
||||
signal.signal(signal.SIGTERM, lambda a, b: p.send_signal(signal.SIGTERM))
|
||||
try:
|
||||
p.wait()
|
||||
except:
|
||||
p.send_signal(signal.SIGTERM)
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
Reference in New Issue
Block a user