diff --git a/db_transfer.py b/db_transfer.py index ae65939..61a7255 100644 --- a/db_transfer.py +++ b/db_transfer.py @@ -78,9 +78,11 @@ class DbTransfer(object): #数据库所有用户信息 try: import switchrule + reload(switchrule) keys = switchrule.getKeys() except Exception as e: keys = ['port', 'u', 'd', 'transfer_enable', 'passwd', 'enable' ] + reload(cymysql) conn = cymysql.connect(host=Config.MYSQL_HOST, port=Config.MYSQL_PORT, user=Config.MYSQL_USER, passwd=Config.MYSQL_PASS, db=Config.MYSQL_DB, charset='utf8') cur = conn.cursor() @@ -102,6 +104,7 @@ class DbTransfer(object): #需要动态载入switchrule,以便实时修改规则 try: import switchrule + reload(switchrule) except Exception as e: logging.error('load switchrule.py fail') cur_servers = {} diff --git a/run.sh b/run.sh index 2925a5e..8fceb97 100644 --- a/run.sh +++ b/run.sh @@ -1,5 +1,6 @@ #!/bin/bash cd `dirname $0` -eval $(ps -ef | grep "[0-9] python server\\.py" | awk '{print "kill "$2}') -nohup python server.py >> ssserver.log 2>&1 & +eval $(ps -ef | grep "[0-9] python server\\.py m" | awk '{print "kill "$2}') +ulimit -n 131072 +nohup python server.py m>> ssserver.log 2>&1 & diff --git a/server.py b/server.py index 585380f..9bd538e 100644 --- a/server.py +++ b/server.py @@ -7,6 +7,7 @@ os.chdir(os.path.split(os.path.realpath(__file__))[0]) import server_pool import db_transfer +from shadowsocks import shell #def test(): # thread.start_new_thread(DbTransfer.thread_db, ()) @@ -19,10 +20,16 @@ class MainThread(threading.Thread): def run(self): db_transfer.DbTransfer.thread_db() +def main(): + shell.check_python() + if len(sys.argv) <= 3: + db_transfer.DbTransfer.thread_db() + else: + thread = MainThread() + thread.start() + while True: + time.sleep(99999) + if __name__ == '__main__': - #server_pool.ServerPool.get_instance() - #server_pool.ServerPool.get_instance().new_server(2333, '2333') - thread = MainThread() - thread.start() - while True: - time.sleep(99999) + main() + diff --git a/stop.sh b/stop.sh index 2fa55cf..c726221 100644 --- a/stop.sh +++ b/stop.sh @@ -1,3 +1,3 @@ #!/bin/bash -eval $(ps -ef | grep "[0-9] python server\\.py" | awk '{print "kill "$2}') +eval $(ps -ef | grep "[0-9] python server\\.py m" | awk '{print "kill "$2}') diff --git a/tail.sh b/tail.sh index aa37139..f36f605 100644 --- a/tail.sh +++ b/tail.sh @@ -1,3 +1,3 @@ #!/bin/bash - +cd `dirname $0` tail -f ssserver.log