Commit b1bf38f3 authored by Nong Hoang Tu's avatar Nong Hoang Tu
Browse files

Change start / stop code structure

parent 15f0f880
Pipeline #3785 canceled with stages
......@@ -33,12 +33,22 @@ proc check_ip() =
proc start() =
# Start Anonsurf's Daemon
ansurf_acts_handle_start(sudo, callback_kill_apps, callback_msg_proc)
if getServStatus("anonsurfd") == 0:
callback_msg_proc("AnonSurf Status", "AnonSurf is running. Can't start it again", 2)
return
callback_kill_apps(callback_msg_proc)
ansurf_acts_handle_start(sudo, callback_msg_proc)
proc stop() =
# Stop Anonsurf's Daemon
if getServStatus("anonsurfd") != 0:
callback_msg_proc("AnonSurf Status", "AnonSurf is not running. Can't stop it", 2)
return
ansurf_acts_handle_stop(sudo, callback_kill_apps, callback_msg_proc)
if getServStatus("anonsurfd") == 3: # status 3 == not running
callback_kill_apps(callback_msg_proc)
proc restart() =
......
......@@ -19,13 +19,7 @@ proc cli_init_callback_msg*(isDesktop: bool): proc =
return cli_send_msg
proc ansurf_acts_handle_start*(sudo: string, callback_kill_apps, callback_send_messages: proc) =
if getServStatus("anonsurfd") == 0:
callback_send_messages("AnonSurf Status", "AnonSurf is running. Can't start it again", 2)
return
callback_kill_apps(callback_send_messages)
proc ansurf_acts_handle_start*(sudo: string, callback_send_messages: proc) =
let status_start_surf = ansurf_core_start(sudo)
if status_start_surf == 0:
if getServStatus("anonsurfd") == 0:
......@@ -43,14 +37,9 @@ proc ansurf_acts_handle_start*(sudo: string, callback_kill_apps, callback_send_m
proc ansurf_acts_handle_stop*(sudo: string, callback_kill_apps, callback_send_messages: proc) =
if getServStatus("anonsurfd") != 0:
callback_send_messages("AnonSurf Status", "AnonSurf is not running. Can't stop it", 2)
return
let stop_status = ansurf_core_stop(sudo)
if stop_status == 0:
callback_send_messages("AnonSurf Stop", "AnonSurf stopped", 0)
callback_kill_apps(callback_send_messages)
elif stop_status == 255:
discard
else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment