Ver código fonte

재시작 관련 수정

잉여개발기 1 ano atrás
pai
commit
e50e7d1e48
2 arquivos alterados com 9 adições e 2 exclusões
  1. 1 1
      app.py
  2. 8 1
      route/main_sys_restart.py

+ 1 - 1
app.py

@@ -940,7 +940,7 @@ app.route('/image/<path:name>')(main_view_image)
 app.route('/<regex("[^.]+\\.(?:txt|xml|ico)"):data>')(main_view_file)
 
 app.route('/shutdown', methods = ['POST', 'GET'])(main_sys_shutdown)
-app.route('/restart', methods = ['POST', 'GET'])(main_sys_restart)
+app.route('/restart', defaults = { 'golang_process' : golang_process }, methods = ['POST', 'GET'])(main_sys_restart)
 app.route('/update', defaults = { 'golang_process' : golang_process }, methods = ['POST', 'GET'])(main_sys_update)
 
 app.errorhandler(404)(main_func_error_404)

+ 8 - 1
route/main_sys_restart.py

@@ -25,7 +25,7 @@ async def main_sys_restart_do():
     else:
         return 0
 
-async def main_sys_restart():
+async def main_sys_restart(golang_process):
     with get_db_connect() as conn:
         if await acl_check('', 'owner_auth', '', '') == 1:
             return await re_error(conn, 3)
@@ -33,6 +33,13 @@ async def main_sys_restart():
         if flask.request.method == 'POST':
             await acl_check(tool = 'owner_auth', memo = 'restart')
 
+            if golang_process.poll() is None:
+                golang_process.terminate()
+                try:
+                    golang_process.wait(timeout = 5)
+                except subprocess.TimeoutExpired:
+                    golang_process.kill()
+
             if await main_sys_restart_do() == 0:
                 return await re_error(conn, 33)
         else: