def update_rules(): pid = proc.get_pid(PID_PATH) if pid < 0: sys.stderr.write("not found process\r\n") sys.stderr.flush() return os.kill(pid, signal.SIGUSR1)
def main(): help_doc = """ start | stop | debug | reload """ if len(sys.argv) != 2: print(help_doc) return if sys.argv[1] not in ("start", "stop", "debug", "reload",): print(help_doc) return d = sys.argv[1] if d == "stop": pid = proc.get_pid(PID_PATH) if pid > 0: os.kill(pid, signal.SIGINT) return if d == "debug": debug = True else: debug = False start(debug)
def __update_host_rules(): pid = proc.get_pid(PID_FILE) if pid < 0: print("fdslight process not exists") return os.kill(pid, signal.SIGUSR1)
def __update_user_configs(): pid = proc.get_pid(PID_FILE) if pid < 0: print("cannot found fdslight server process") return os.kill(pid, signal.SIGUSR1)
def __stop_service(): pid = proc.get_pid(PID_FILE) if pid < 0: print("cannot found fdslight server process") return os.kill(pid, signal.SIGINT)
def main(): help_doc = """ start | stop | debug start | debug --wol_listen_port=port --wol_key=key --wol_bind_ip=ip """ if len(sys.argv) < 2: print(help_doc) return if sys.argv[1] not in ("start", "stop", "debug",): print(help_doc) return d = sys.argv[1] if d == "stop": pid = proc.get_pid(PID_PATH) if pid > 0: os.kill(pid, signal.SIGINT) return try: opts, args = getopt.getopt(sys.argv[2:], "", ["wol_listen_port=", "wol_key=", "wol_bind_ip="]) except getopt.GetoptError: print(help_doc) return except IndexError: print(help_doc) return wol_port = 5888 wol_key = None wol_bind_ip = None for k, v in opts: if k == "--wol_listen_port": if not cfg_check.is_port(v): sys.stderr.write("wrong port number\r\n") return wol_port = int(v) if k == "--wol_key": wol_key = v if k == "--wol_bind_ip": wol_bind_ip = v '''''' if not wol_key: sys.stderr.write("please set wol key\r\n") return if not wol_bind_ip: sys.stderr.write("please set wol bind ip") return if d == "debug": debug = True else: debug = False start(debug, wol_key, wol_port, wol_bind_ip)
def main(): help_doc = """ -d debug | start | stop debug,start or stop application """ try: opts, args = getopt.getopt(sys.argv[1:], "u:m:d:") except getopt.GetoptError: print(help_doc) return d = None if sys.platform.find("win32") > -1: is_windows = True else: is_windows = False for k, v in opts: if k == "-d": d = v if d not in ("debug", "start", "stop"): print(help_doc) return if is_windows and d in ("start", "stop",): sys.stderr.write("windows only support -d start argument") return if d == "stop": pid = proc.get_pid(PID_PATH) if pid > 0: os.kill(pid, signal.SIGINT) return debug = True if d == "start": if os.path.exists(PID_PATH): print("the process s2hss exists,please delete %s or kill it at first" % PID_PATH) return debug = False pid = os.fork() if pid != 0: sys.exit(0) os.setsid() os.umask(0) pid = os.fork() if pid != 0: sys.exit(0) proc.write_pid(PID_PATH) cls = serverd() try: cls.ioloop(debug=debug) except KeyboardInterrupt: cls.release()
def __stop_service(): pid = proc.get_pid(PID_FILE) if pid < 0: return os.kill(pid, signal.SIGINT)
def main(): help_doc = """ -d debug | start | stop debug,start or stop application -m relay | proxy relay mode,proxy mode or all mode -u update rule files --with-dnsserver enable DNS server support """ try: opts, args = getopt.getopt(sys.argv[1:], "m:d:u", ["with-dnsserver"]) except getopt.GetoptError as e: print(help_doc) return d = None m = None u = None enable_dns = False if sys.platform.find("win32") > -1: is_windows = True else: is_windows = False for k, v in opts: if k == "-d": d = v if k == "-m": m = v if k == "-u": u = True if k == "--with-dnsserver": enable_dns = True if u and (d or m): print(help_doc) return if u and enable_dns: print(help_doc) return if u: update_rules() return if d not in ("debug", "start", "stop"): print(help_doc) return if is_windows and d in ("start", "stop",): sys.stderr.write("windows only support -d debug") return if m not in ("relay", "proxy"): print(help_doc) return if d == "stop": pid = proc.get_pid(PID_PATH) if pid > 0: os.kill(pid, signal.SIGINT) return debug = True if d == "start": if os.path.exists(PID_PATH): print("the process s2hsc exists,please delete %s or kill it at first" % PID_PATH) return debug = False pid = os.fork() if pid != 0: sys.exit(0) os.setsid() os.umask(0) pid = os.fork() if pid != 0: sys.exit(0) proc.write_pid(PID_PATH) cls = serverd() try: cls.ioloop(m, with_dnsserver=enable_dns, debug=debug) except KeyboardInterrupt: cls.release()
def stop(): pid = proc.get_pid(PID_PATH) if pid < 0: return os.remove(PID_PATH) os.kill(pid, signal.SIGINT)