'This manages the flag file that tells the runner if the server is
reloading, resetting or shutting down.
Args:
mode (string or None, optional): Valid values are
\'reload\', \'reset\', \'shutdown\' and `None`. If mode is `None`,
no change will be done to the flag file.
Returns:
mode (str): The currently active restart mode, either just
set or previously set.'

def getset_restart_mode(self, mode=None):

    if (mode is None):
        with open(SERVER_RESTART, 'r') as f:
            mode = f.read()
    else:
        with open(SERVER_RESTART, 'w') as f:
            f.write(str(mode))
    return mode
