+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/rockstor/storageadmin/views/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,14 @@ def post(self, request, command, rtcepoch=None):
).format(e.__str__())
handle_exception(Exception(e_msg), request)

# default has shutdown and reboot with delay set to now
# having normal sytem power off with now = 1 min
# reboot and shutdown requests from WebUI don't have request.auth
# while same requests over rest api (ex. scheduled tasks) have
# an auth token, so if we detect a token we delay with 3 mins
# to grant connected WebUI user to close it or cancel shutdown/reboot
delay = "now"
# Default has shutdown and reboot with delay set to "now".
# Reboot and shutdown requests from WebUI don't have request.auth,
# while same requests over rest api (e.g. scheduled tasks) have
# an auth token, so if we detect a token we set delay to 3 minutes
# to notify cli users ahead of time.
delay: str = "now"
if request.auth is not None:
delay = 3
delay = "3"

if command == "shutdown":
msg = "The system will now be shutdown."
Expand Down
8 changes: 4 additions & 4 deletions src/rockstor/system/osi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1363,11 +1363,11 @@ def get_virtio_disk_serial(device_name):
return out[0]


def system_shutdown(delta="now"):
def system_shutdown(delta: str = "now"):
# New delta param default to now used to pass a 2 min delay
# for scheduled tasks reboot/shutdown
try:
cmd = [SHUTDOWN, "-h", delta]
cmd: list[str] = [SHUTDOWN, "-h", delta]
o, e, rc = run_command(cmd)
except CommandException as e:
# Catch / log harmless -15 return code - command executes as expected.
Expand All @@ -1379,11 +1379,11 @@ def system_shutdown(delta="now"):
return o, e, rc


def system_reboot(delta="now"):
def system_reboot(delta: str = "now"):
# New delta param default to now used to pass a 2 min delay
# for scheduled tasks reboot/shutdown
try:
cmd = [SHUTDOWN, "-r", delta]
cmd: list[str] = [SHUTDOWN, "-r", delta]
o, e, rc = run_command(cmd)
except CommandException as e:
# Catch / log harmless -15 return code - command executes as expected.
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载