def server_operation(mode, service, interactive, profiler, logserver=False):
    """
    Handle argument options given on the command line.

    Args:
        mode (str): Start/stop/restart and so on.
        service (str): "server", "portal" or "all".
        interactive (bool). Use interactive mode or daemon.
        profiler (bool): Run the service under the profiler.
        logserver (bool, optional): Log Server data to logfile
            specified by settings.SERVER_LOG_FILE.

    """

    cmdstr = [sys.executable, EVENNIA_RUNNER]
    errmsg = "The %s does not seem to be running."

    if mode == 'start':

        # launch the error checker. Best to catch the errors already here.
        error_check_python_modules()

        # starting one or many services
        if service == 'server':
            if profiler:
                cmdstr.append('--pserver')
            if interactive:
                cmdstr.append('--iserver')
            if logserver:
                cmdstr.append('--logserver')
            cmdstr.append('--noportal')
        elif service == 'portal':
            if profiler:
                cmdstr.append('--pportal')
            if interactive:
                cmdstr.append('--iportal')
            cmdstr.append('--noserver')
            django.core.management.call_command(
                'collectstatic', verbosity=1, interactive=False)
        else:
            # all
            # for convenience we don't start logging of
            # portal, only of server with this command.
            if profiler:
                # this is the common case
                cmdstr.append('--pserver')
            if interactive:
                cmdstr.append('--iserver')
            if logserver:
                cmdstr.append('--logserver')
            django.core.management.call_command(
                'collectstatic', verbosity=1, interactive=False)
        cmdstr.extend([
            GAMEDIR, TWISTED_BINARY, SERVER_LOGFILE,
            PORTAL_LOGFILE, HTTP_LOGFILE])
        # start the server
        process = Popen(cmdstr, env=getenv())

        if interactive:
            try:
                process.wait()
            except KeyboardInterrupt:
                server_operation("stop", "portal", False, False)
                return
            finally:
                print(NOTE_KEYBOARDINTERRUPT)

    elif mode == 'reload':
        # restarting services
        if os.name == 'nt':
            print(
                "Restarting from command line is not supported under Windows. "
                "Log into the game to restart.")
            return
        if service == 'server':
            kill(SERVER_PIDFILE, SIG, "Server reloaded.",
                 errmsg % 'Server', SERVER_RESTART, restart=True)
        elif service == 'portal':
            print(
                "Note: Portal usually doesnt't need to be reloaded unless you "
                "are debugging in interactive mode. If Portal was running in "
                "default Daemon mode, it cannot be restarted. In that case "
                "you have to restart it manually with 'evennia.py "
                "start portal'")
            kill(PORTAL_PIDFILE, SIG,
                 "Portal reloaded (or stopped, if it was in daemon mode).",
                 errmsg % 'Portal', PORTAL_RESTART, restart=True)
        else:
            # all
            # default mode, only restart server
            kill(SERVER_PIDFILE, SIG,
                 "Server reload.",
                 errmsg % 'Server', SERVER_RESTART, restart=True)

    elif mode == 'stop':
        # stop processes, avoiding reload
        if service == 'server':
            kill(SERVER_PIDFILE, SIG,
                 "Server stopped.", errmsg % 'Server', SERVER_RESTART)
        elif service == 'portal':
            kill(PORTAL_PIDFILE, SIG,
                 "Portal stopped.", errmsg % 'Portal', PORTAL_RESTART)
        else:
            kill(PORTAL_PIDFILE, SIG,
                 "Portal stopped.", errmsg % 'Portal', PORTAL_RESTART)
            kill(SERVER_PIDFILE, SIG,
                 "Server stopped.", errmsg % 'Server', SERVER_RESTART)
dataset/ETHPy150Open evennia/evennia/evennia/server/evennia_launcher.py/server_operation/original