We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Startup folder not configured correctly
I think the `app_root="startup"` should be `app_root=startup` [here](https://github.com/NVIDIA/NVFlare/blob/fa20e5e27b01e0f66cbefea229aed2cf6729663d/nvflare/private/fed/app/server/server_train.py#L67-L69)

If you like I can submit a PR?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `nvflare/private/fed/app/server/server_train.py`
Content:
```
1 # Copyright (c) 2021-2022, NVIDIA CORPORATION.  All rights reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 """Provides a command line interface for federated server."""
16 
17 import argparse
18 import logging
19 import os
20 import sys
21 
22 from nvflare.fuel.common.excepts import ConfigError
23 from nvflare.fuel.hci.server.authz import AuthorizationService
24 from nvflare.fuel.sec.audit import AuditService
25 from nvflare.fuel.sec.security_content_service import LoadResult, SecurityContentService
26 from nvflare.fuel.utils.argument_utils import parse_vars
27 from nvflare.private.fed.app.fl_conf import FLServerStarterConfiger
28 from nvflare.private.fed.server.admin import FedAdminServer
29 from nvflare.security.security import EmptyAuthorizer, FLAuthorizer
30 
31 
32 def main():
33     """FL Server program starting point."""
34     parser = argparse.ArgumentParser()
35     parser.add_argument("--workspace", "-m", type=str, help="WORKSPACE folder", required=True)
36 
37     parser.add_argument(
38         "--fed_server", "-s", type=str, help="an aggregation server specification json file", required=True
39     )
40 
41     parser.add_argument("--set", metavar="KEY=VALUE", nargs="*")
42 
43     args = parser.parse_args()
44     kv_list = parse_vars(args.set)
45 
46     args.train_config = "config/config_train.json"
47     config_folder = kv_list.get("config_folder", "")
48     if config_folder == "":
49         args.server_config = "config_fed_server.json"
50     else:
51         args.server_config = config_folder + "/config_fed_server.json"
52     args.env = "config/environment.json"
53     args.config_folder = config_folder
54     logger = logging.getLogger()
55     args.log_config = None
56 
57     try:
58         remove_restart_file(args)
59     except BaseException:
60         print("Could not remove the restart.fl / shutdown.fl file.  Please check your system before starting FL.")
61         sys.exit(-1)
62 
63     try:
64         os.chdir(args.workspace)
65 
66         # trainer = WorkFlowFactory().create_server_trainer(train_configs, envs)
67         startup = os.path.join(args.workspace, "startup")
68         conf = FLServerStarterConfiger(
69             app_root="startup",
70             # wf_config_file_name="config_train.json",
71             server_config_file_name=args.fed_server,
72             # env_config_file_name="environment.json",
73             log_config_file_name="log.config",
74             kv_list=args.set,
75         )
76         log_level = os.environ.get("FL_LOG_LEVEL", "")
77         numeric_level = getattr(logging, log_level.upper(), None)
78         if isinstance(numeric_level, int):
79             logging.getLogger().setLevel(numeric_level)
80             logger.debug("loglevel debug enabled")
81             logger.info("loglevel info enabled")
82             logger.warning("loglevel warn enabled")
83             logger.error("loglevel error enabled")
84             logger.critical("loglevel critical enabled")
85         conf.configure()
86 
87         deployer = conf.deployer
88         secure_train = conf.cmd_vars.get("secure_train", False)
89 
90         security_check(secure_train, args)
91 
92         try:
93             # Deploy the FL server
94             services = deployer.deploy(args)
95 
96             first_server = sorted(conf.config_data["servers"])[0]
97             # allow command to overwrite the admin_host
98             if conf.cmd_vars.get("host", None):
99                 first_server["admin_host"] = conf.cmd_vars["host"]
100             admin_server = create_admin_server(
101                 services,
102                 server_conf=first_server,
103                 args=args,
104                 secure_train=secure_train,
105                 app_validator=deployer.app_validator,
106             )
107             admin_server.start()
108 
109             services.platform = "PT"
110 
111             services.set_admin_server(admin_server)
112         finally:
113             deployer.close()
114 
115         logger.info("Server started")
116 
117     except ConfigError as ex:
118         print("ConfigError:", str(ex))
119     finally:
120         pass
121 
122 
123 def security_check(secure_train, args):
124     """To check the security content if running in security mode.
125 
126     Args:
127         secure_train: True/False
128         args: command args
129 
130     """
131     # initialize the SecurityContentService.
132     # must do this before initializing other services since it may be needed by them!
133     startup = os.path.join(args.workspace, "startup")
134     SecurityContentService.initialize(content_folder=startup)
135 
136     if secure_train:
137         insecure_list = secure_content_check(args)
138         if len(insecure_list):
139             print("The following files are not secure content.")
140             for item in insecure_list:
141                 print(item)
142             sys.exit(1)
143 
144     # initialize the AuditService, which is used by command processing.
145     # The Audit Service can be used in other places as well.
146     AuditService.initialize(audit_file_name="audit.log")
147     # Initialize the AuthorizationService. It is used by command authorization
148     # We use FLAuthorizer for policy processing.
149     # AuthorizationService depends on SecurityContentService to read authorization policy file.
150     if secure_train:
151         _, err = AuthorizationService.initialize(FLAuthorizer())
152     else:
153         _, err = AuthorizationService.initialize(EmptyAuthorizer())
154 
155     if err:
156         print("AuthorizationService error: {}".format(err))
157         sys.exit(1)
158 
159 
160 def secure_content_check(args):
161     """To check the security contents.
162 
163     Args:
164         args: command args
165 
166     Returns: the insecure content list
167 
168     """
169     insecure_list = []
170     data, sig = SecurityContentService.load_json(args.fed_server)
171     if sig != LoadResult.OK:
172         insecure_list.append(args.fed_server)
173 
174     for server in data["servers"]:
175         content, sig = SecurityContentService.load_content(server.get("ssl_cert"))
176         if sig != LoadResult.OK:
177             insecure_list.append(server.get("ssl_cert"))
178         content, sig = SecurityContentService.load_content(server.get("ssl_private_key"))
179         if sig != LoadResult.OK:
180             insecure_list.append(server.get("ssl_private_key"))
181         content, sig = SecurityContentService.load_content(server.get("ssl_root_cert"))
182         if sig != LoadResult.OK:
183             insecure_list.append(server.get("ssl_root_cert"))
184 
185     if "authorization.json" in SecurityContentService.security_content_manager.signature:
186         data, sig = SecurityContentService.load_json("authorization.json")
187         if sig != LoadResult.OK:
188             insecure_list.append("authorization.json")
189 
190     return insecure_list
191 
192 
193 def remove_restart_file(args):
194     """To remove the restart.fl file.
195 
196     Args:
197         args: command args
198 
199     """
200     restart_file = os.path.join(args.workspace, "restart.fl")
201     if os.path.exists(restart_file):
202         os.remove(restart_file)
203     restart_file = os.path.join(args.workspace, "shutdown.fl")
204     if os.path.exists(restart_file):
205         os.remove(restart_file)
206 
207 
208 def create_admin_server(fl_server, server_conf=None, args=None, secure_train=False, app_validator=None):
209     """To create the admin server.
210 
211     Args:
212         fl_server: fl_server
213         server_conf: server config
214         args: command args
215         secure_train: True/False
216         app_validator: application validator
217 
218     Returns: admin server
219 
220     """
221     # sai = ServerEngine(fl_server, args)
222     users = {}
223     # Create a default user admin:admin for the POC insecure use case.
224     if not secure_train:
225         users = {
226             "admin": "e7b71aa322cecc502e9454271b98feaec594da944c369facc90ac85016dc6c74c3fd99657ebd9d083a7804c3a17ddd8c655df8bcbf172be9d0207c8c9430c19be3cd846949505d283e066434175956bf45cd1d6781e63e5be4f3e23533d4d002"
227         }
228     # cmd_modules = [ValidationCommandModule()]
229 
230     root_cert = server_conf["ssl_root_cert"] if secure_train else None
231     server_cert = server_conf["ssl_cert"] if secure_train else None
232     server_key = server_conf["ssl_private_key"] if secure_train else None
233     admin_server = FedAdminServer(
234         fed_admin_interface=fl_server.engine,
235         users=users,
236         cmd_modules=fl_server.cmd_modules,
237         file_upload_dir=os.path.join(args.workspace, server_conf.get("admin_storage", "tmp")),
238         file_download_dir=os.path.join(args.workspace, server_conf.get("admin_storage", "tmp")),
239         allowed_shell_cmds=None,
240         host=server_conf.get("admin_host", "localhost"),
241         port=server_conf.get("admin_port", 5005),
242         ca_cert_file_name=root_cert,
243         server_cert_file_name=server_cert,
244         server_key_file_name=server_key,
245         accepted_client_cns=None,
246         app_validator=app_validator,
247     )
248     return admin_server
249 
250 
251 if __name__ == "__main__":
252     """
253     This is the main program when starting the NVIDIA FLARE server process.
254     """
255 
256     main()
257
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/nvflare/private/fed/app/server/server_train.py b/nvflare/private/fed/app/server/server_train.py
--- a/nvflare/private/fed/app/server/server_train.py
+++ b/nvflare/private/fed/app/server/server_train.py
@@ -66,7 +66,7 @@
         # trainer = WorkFlowFactory().create_server_trainer(train_configs, envs)
         startup = os.path.join(args.workspace, "startup")
         conf = FLServerStarterConfiger(
-            app_root="startup",
+            app_root=startup,
             # wf_config_file_name="config_train.json",
             server_config_file_name=args.fed_server,
             # env_config_file_name="environment.json",

{"golden_diff": "diff --git a/nvflare/private/fed/app/server/server_train.py b/nvflare/private/fed/app/server/server_train.py\n--- a/nvflare/private/fed/app/server/server_train.py\n+++ b/nvflare/private/fed/app/server/server_train.py\n@@ -66,7 +66,7 @@\n         # trainer = WorkFlowFactory().create_server_trainer(train_configs, envs)\n         startup = os.path.join(args.workspace, \"startup\")\n         conf = FLServerStarterConfiger(\n-            app_root=\"startup\",\n+            app_root=startup,\n             # wf_config_file_name=\"config_train.json\",\n             server_config_file_name=args.fed_server,\n             # env_config_file_name=\"environment.json\",\n", "issue": "Startup folder not configured correctly\nI think the `app_root=\"startup\"` should be `app_root=startup` [here](https://github.com/NVIDIA/NVFlare/blob/fa20e5e27b01e0f66cbefea229aed2cf6729663d/nvflare/private/fed/app/server/server_train.py#L67-L69)\r\n\r\nIf you like I can submit a PR?\n", "before_files": [{"content": "# Copyright (c) 2021-2022, NVIDIA CORPORATION.  All rights reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Provides a command line interface for federated server.\"\"\"\n\nimport argparse\nimport logging\nimport os\nimport sys\n\nfrom nvflare.fuel.common.excepts import ConfigError\nfrom nvflare.fuel.hci.server.authz import AuthorizationService\nfrom nvflare.fuel.sec.audit import AuditService\nfrom nvflare.fuel.sec.security_content_service import LoadResult, SecurityContentService\nfrom nvflare.fuel.utils.argument_utils import parse_vars\nfrom nvflare.private.fed.app.fl_conf import FLServerStarterConfiger\nfrom nvflare.private.fed.server.admin import FedAdminServer\nfrom nvflare.security.security import EmptyAuthorizer, FLAuthorizer\n\n\ndef main():\n    \"\"\"FL Server program starting point.\"\"\"\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\"--workspace\", \"-m\", type=str, help=\"WORKSPACE folder\", required=True)\n\n    parser.add_argument(\n        \"--fed_server\", \"-s\", type=str, help=\"an aggregation server specification json file\", required=True\n    )\n\n    parser.add_argument(\"--set\", metavar=\"KEY=VALUE\", nargs=\"*\")\n\n    args = parser.parse_args()\n    kv_list = parse_vars(args.set)\n\n    args.train_config = \"config/config_train.json\"\n    config_folder = kv_list.get(\"config_folder\", \"\")\n    if config_folder == \"\":\n        args.server_config = \"config_fed_server.json\"\n    else:\n        args.server_config = config_folder + \"/config_fed_server.json\"\n    args.env = \"config/environment.json\"\n    args.config_folder = config_folder\n    logger = logging.getLogger()\n    args.log_config = None\n\n    try:\n        remove_restart_file(args)\n    except BaseException:\n        print(\"Could not remove the restart.fl / shutdown.fl file.  Please check your system before starting FL.\")\n        sys.exit(-1)\n\n    try:\n        os.chdir(args.workspace)\n\n        # trainer = WorkFlowFactory().create_server_trainer(train_configs, envs)\n        startup = os.path.join(args.workspace, \"startup\")\n        conf = FLServerStarterConfiger(\n            app_root=\"startup\",\n            # wf_config_file_name=\"config_train.json\",\n            server_config_file_name=args.fed_server,\n            # env_config_file_name=\"environment.json\",\n            log_config_file_name=\"log.config\",\n            kv_list=args.set,\n        )\n        log_level = os.environ.get(\"FL_LOG_LEVEL\", \"\")\n        numeric_level = getattr(logging, log_level.upper(), None)\n        if isinstance(numeric_level, int):\n            logging.getLogger().setLevel(numeric_level)\n            logger.debug(\"loglevel debug enabled\")\n            logger.info(\"loglevel info enabled\")\n            logger.warning(\"loglevel warn enabled\")\n            logger.error(\"loglevel error enabled\")\n            logger.critical(\"loglevel critical enabled\")\n        conf.configure()\n\n        deployer = conf.deployer\n        secure_train = conf.cmd_vars.get(\"secure_train\", False)\n\n        security_check(secure_train, args)\n\n        try:\n            # Deploy the FL server\n            services = deployer.deploy(args)\n\n            first_server = sorted(conf.config_data[\"servers\"])[0]\n            # allow command to overwrite the admin_host\n            if conf.cmd_vars.get(\"host\", None):\n                first_server[\"admin_host\"] = conf.cmd_vars[\"host\"]\n            admin_server = create_admin_server(\n                services,\n                server_conf=first_server,\n                args=args,\n                secure_train=secure_train,\n                app_validator=deployer.app_validator,\n            )\n            admin_server.start()\n\n            services.platform = \"PT\"\n\n            services.set_admin_server(admin_server)\n        finally:\n            deployer.close()\n\n        logger.info(\"Server started\")\n\n    except ConfigError as ex:\n        print(\"ConfigError:\", str(ex))\n    finally:\n        pass\n\n\ndef security_check(secure_train, args):\n    \"\"\"To check the security content if running in security mode.\n\n    Args:\n        secure_train: True/False\n        args: command args\n\n    \"\"\"\n    # initialize the SecurityContentService.\n    # must do this before initializing other services since it may be needed by them!\n    startup = os.path.join(args.workspace, \"startup\")\n    SecurityContentService.initialize(content_folder=startup)\n\n    if secure_train:\n        insecure_list = secure_content_check(args)\n        if len(insecure_list):\n            print(\"The following files are not secure content.\")\n            for item in insecure_list:\n                print(item)\n            sys.exit(1)\n\n    # initialize the AuditService, which is used by command processing.\n    # The Audit Service can be used in other places as well.\n    AuditService.initialize(audit_file_name=\"audit.log\")\n    # Initialize the AuthorizationService. It is used by command authorization\n    # We use FLAuthorizer for policy processing.\n    # AuthorizationService depends on SecurityContentService to read authorization policy file.\n    if secure_train:\n        _, err = AuthorizationService.initialize(FLAuthorizer())\n    else:\n        _, err = AuthorizationService.initialize(EmptyAuthorizer())\n\n    if err:\n        print(\"AuthorizationService error: {}\".format(err))\n        sys.exit(1)\n\n\ndef secure_content_check(args):\n    \"\"\"To check the security contents.\n\n    Args:\n        args: command args\n\n    Returns: the insecure content list\n\n    \"\"\"\n    insecure_list = []\n    data, sig = SecurityContentService.load_json(args.fed_server)\n    if sig != LoadResult.OK:\n        insecure_list.append(args.fed_server)\n\n    for server in data[\"servers\"]:\n        content, sig = SecurityContentService.load_content(server.get(\"ssl_cert\"))\n        if sig != LoadResult.OK:\n            insecure_list.append(server.get(\"ssl_cert\"))\n        content, sig = SecurityContentService.load_content(server.get(\"ssl_private_key\"))\n        if sig != LoadResult.OK:\n            insecure_list.append(server.get(\"ssl_private_key\"))\n        content, sig = SecurityContentService.load_content(server.get(\"ssl_root_cert\"))\n        if sig != LoadResult.OK:\n            insecure_list.append(server.get(\"ssl_root_cert\"))\n\n    if \"authorization.json\" in SecurityContentService.security_content_manager.signature:\n        data, sig = SecurityContentService.load_json(\"authorization.json\")\n        if sig != LoadResult.OK:\n            insecure_list.append(\"authorization.json\")\n\n    return insecure_list\n\n\ndef remove_restart_file(args):\n    \"\"\"To remove the restart.fl file.\n\n    Args:\n        args: command args\n\n    \"\"\"\n    restart_file = os.path.join(args.workspace, \"restart.fl\")\n    if os.path.exists(restart_file):\n        os.remove(restart_file)\n    restart_file = os.path.join(args.workspace, \"shutdown.fl\")\n    if os.path.exists(restart_file):\n        os.remove(restart_file)\n\n\ndef create_admin_server(fl_server, server_conf=None, args=None, secure_train=False, app_validator=None):\n    \"\"\"To create the admin server.\n\n    Args:\n        fl_server: fl_server\n        server_conf: server config\n        args: command args\n        secure_train: True/False\n        app_validator: application validator\n\n    Returns: admin server\n\n    \"\"\"\n    # sai = ServerEngine(fl_server, args)\n    users = {}\n    # Create a default user admin:admin for the POC insecure use case.\n    if not secure_train:\n        users = {\n            \"admin\": \"e7b71aa322cecc502e9454271b98feaec594da944c369facc90ac85016dc6c74c3fd99657ebd9d083a7804c3a17ddd8c655df8bcbf172be9d0207c8c9430c19be3cd846949505d283e066434175956bf45cd1d6781e63e5be4f3e23533d4d002\"\n        }\n    # cmd_modules = [ValidationCommandModule()]\n\n    root_cert = server_conf[\"ssl_root_cert\"] if secure_train else None\n    server_cert = server_conf[\"ssl_cert\"] if secure_train else None\n    server_key = server_conf[\"ssl_private_key\"] if secure_train else None\n    admin_server = FedAdminServer(\n        fed_admin_interface=fl_server.engine,\n        users=users,\n        cmd_modules=fl_server.cmd_modules,\n        file_upload_dir=os.path.join(args.workspace, server_conf.get(\"admin_storage\", \"tmp\")),\n        file_download_dir=os.path.join(args.workspace, server_conf.get(\"admin_storage\", \"tmp\")),\n        allowed_shell_cmds=None,\n        host=server_conf.get(\"admin_host\", \"localhost\"),\n        port=server_conf.get(\"admin_port\", 5005),\n        ca_cert_file_name=root_cert,\n        server_cert_file_name=server_cert,\n        server_key_file_name=server_key,\n        accepted_client_cns=None,\n        app_validator=app_validator,\n    )\n    return admin_server\n\n\nif __name__ == \"__main__\":\n    \"\"\"\n    This is the main program when starting the NVIDIA FLARE server process.\n    \"\"\"\n\n    main()\n", "path": "nvflare/private/fed/app/server/server_train.py"}], "after_files": [{"content": "# Copyright (c) 2021-2022, NVIDIA CORPORATION.  All rights reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Provides a command line interface for federated server.\"\"\"\n\nimport argparse\nimport logging\nimport os\nimport sys\n\nfrom nvflare.fuel.common.excepts import ConfigError\nfrom nvflare.fuel.hci.server.authz import AuthorizationService\nfrom nvflare.fuel.sec.audit import AuditService\nfrom nvflare.fuel.sec.security_content_service import LoadResult, SecurityContentService\nfrom nvflare.fuel.utils.argument_utils import parse_vars\nfrom nvflare.private.fed.app.fl_conf import FLServerStarterConfiger\nfrom nvflare.private.fed.server.admin import FedAdminServer\nfrom nvflare.security.security import EmptyAuthorizer, FLAuthorizer\n\n\ndef main():\n    \"\"\"FL Server program starting point.\"\"\"\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\"--workspace\", \"-m\", type=str, help=\"WORKSPACE folder\", required=True)\n\n    parser.add_argument(\n        \"--fed_server\", \"-s\", type=str, help=\"an aggregation server specification json file\", required=True\n    )\n\n    parser.add_argument(\"--set\", metavar=\"KEY=VALUE\", nargs=\"*\")\n\n    args = parser.parse_args()\n    kv_list = parse_vars(args.set)\n\n    args.train_config = \"config/config_train.json\"\n    config_folder = kv_list.get(\"config_folder\", \"\")\n    if config_folder == \"\":\n        args.server_config = \"config_fed_server.json\"\n    else:\n        args.server_config = config_folder + \"/config_fed_server.json\"\n    args.env = \"config/environment.json\"\n    args.config_folder = config_folder\n    logger = logging.getLogger()\n    args.log_config = None\n\n    try:\n        remove_restart_file(args)\n    except BaseException:\n        print(\"Could not remove the restart.fl / shutdown.fl file.  Please check your system before starting FL.\")\n        sys.exit(-1)\n\n    try:\n        os.chdir(args.workspace)\n\n        # trainer = WorkFlowFactory().create_server_trainer(train_configs, envs)\n        startup = os.path.join(args.workspace, \"startup\")\n        conf = FLServerStarterConfiger(\n            app_root=startup,\n            # wf_config_file_name=\"config_train.json\",\n            server_config_file_name=args.fed_server,\n            # env_config_file_name=\"environment.json\",\n            log_config_file_name=\"log.config\",\n            kv_list=args.set,\n        )\n        log_level = os.environ.get(\"FL_LOG_LEVEL\", \"\")\n        numeric_level = getattr(logging, log_level.upper(), None)\n        if isinstance(numeric_level, int):\n            logging.getLogger().setLevel(numeric_level)\n            logger.debug(\"loglevel debug enabled\")\n            logger.info(\"loglevel info enabled\")\n            logger.warning(\"loglevel warn enabled\")\n            logger.error(\"loglevel error enabled\")\n            logger.critical(\"loglevel critical enabled\")\n        conf.configure()\n\n        deployer = conf.deployer\n        secure_train = conf.cmd_vars.get(\"secure_train\", False)\n\n        security_check(secure_train, args)\n\n        try:\n            # Deploy the FL server\n            services = deployer.deploy(args)\n\n            first_server = sorted(conf.config_data[\"servers\"])[0]\n            # allow command to overwrite the admin_host\n            if conf.cmd_vars.get(\"host\", None):\n                first_server[\"admin_host\"] = conf.cmd_vars[\"host\"]\n            admin_server = create_admin_server(\n                services,\n                server_conf=first_server,\n                args=args,\n                secure_train=secure_train,\n                app_validator=deployer.app_validator,\n            )\n            admin_server.start()\n\n            services.platform = \"PT\"\n\n            services.set_admin_server(admin_server)\n        finally:\n            deployer.close()\n\n        logger.info(\"Server started\")\n\n    except ConfigError as ex:\n        print(\"ConfigError:\", str(ex))\n    finally:\n        pass\n\n\ndef security_check(secure_train, args):\n    \"\"\"To check the security content if running in security mode.\n\n    Args:\n        secure_train: True/False\n        args: command args\n\n    \"\"\"\n    # initialize the SecurityContentService.\n    # must do this before initializing other services since it may be needed by them!\n    startup = os.path.join(args.workspace, \"startup\")\n    SecurityContentService.initialize(content_folder=startup)\n\n    if secure_train:\n        insecure_list = secure_content_check(args)\n        if len(insecure_list):\n            print(\"The following files are not secure content.\")\n            for item in insecure_list:\n                print(item)\n            sys.exit(1)\n\n    # initialize the AuditService, which is used by command processing.\n    # The Audit Service can be used in other places as well.\n    AuditService.initialize(audit_file_name=\"audit.log\")\n    # Initialize the AuthorizationService. It is used by command authorization\n    # We use FLAuthorizer for policy processing.\n    # AuthorizationService depends on SecurityContentService to read authorization policy file.\n    if secure_train:\n        _, err = AuthorizationService.initialize(FLAuthorizer())\n    else:\n        _, err = AuthorizationService.initialize(EmptyAuthorizer())\n\n    if err:\n        print(\"AuthorizationService error: {}\".format(err))\n        sys.exit(1)\n\n\ndef secure_content_check(args):\n    \"\"\"To check the security contents.\n\n    Args:\n        args: command args\n\n    Returns: the insecure content list\n\n    \"\"\"\n    insecure_list = []\n    data, sig = SecurityContentService.load_json(args.fed_server)\n    if sig != LoadResult.OK:\n        insecure_list.append(args.fed_server)\n\n    for server in data[\"servers\"]:\n        content, sig = SecurityContentService.load_content(server.get(\"ssl_cert\"))\n        if sig != LoadResult.OK:\n            insecure_list.append(server.get(\"ssl_cert\"))\n        content, sig = SecurityContentService.load_content(server.get(\"ssl_private_key\"))\n        if sig != LoadResult.OK:\n            insecure_list.append(server.get(\"ssl_private_key\"))\n        content, sig = SecurityContentService.load_content(server.get(\"ssl_root_cert\"))\n        if sig != LoadResult.OK:\n            insecure_list.append(server.get(\"ssl_root_cert\"))\n\n    if \"authorization.json\" in SecurityContentService.security_content_manager.signature:\n        data, sig = SecurityContentService.load_json(\"authorization.json\")\n        if sig != LoadResult.OK:\n            insecure_list.append(\"authorization.json\")\n\n    return insecure_list\n\n\ndef remove_restart_file(args):\n    \"\"\"To remove the restart.fl file.\n\n    Args:\n        args: command args\n\n    \"\"\"\n    restart_file = os.path.join(args.workspace, \"restart.fl\")\n    if os.path.exists(restart_file):\n        os.remove(restart_file)\n    restart_file = os.path.join(args.workspace, \"shutdown.fl\")\n    if os.path.exists(restart_file):\n        os.remove(restart_file)\n\n\ndef create_admin_server(fl_server, server_conf=None, args=None, secure_train=False, app_validator=None):\n    \"\"\"To create the admin server.\n\n    Args:\n        fl_server: fl_server\n        server_conf: server config\n        args: command args\n        secure_train: True/False\n        app_validator: application validator\n\n    Returns: admin server\n\n    \"\"\"\n    # sai = ServerEngine(fl_server, args)\n    users = {}\n    # Create a default user admin:admin for the POC insecure use case.\n    if not secure_train:\n        users = {\n            \"admin\": \"e7b71aa322cecc502e9454271b98feaec594da944c369facc90ac85016dc6c74c3fd99657ebd9d083a7804c3a17ddd8c655df8bcbf172be9d0207c8c9430c19be3cd846949505d283e066434175956bf45cd1d6781e63e5be4f3e23533d4d002\"\n        }\n    # cmd_modules = [ValidationCommandModule()]\n\n    root_cert = server_conf[\"ssl_root_cert\"] if secure_train else None\n    server_cert = server_conf[\"ssl_cert\"] if secure_train else None\n    server_key = server_conf[\"ssl_private_key\"] if secure_train else None\n    admin_server = FedAdminServer(\n        fed_admin_interface=fl_server.engine,\n        users=users,\n        cmd_modules=fl_server.cmd_modules,\n        file_upload_dir=os.path.join(args.workspace, server_conf.get(\"admin_storage\", \"tmp\")),\n        file_download_dir=os.path.join(args.workspace, server_conf.get(\"admin_storage\", \"tmp\")),\n        allowed_shell_cmds=None,\n        host=server_conf.get(\"admin_host\", \"localhost\"),\n        port=server_conf.get(\"admin_port\", 5005),\n        ca_cert_file_name=root_cert,\n        server_cert_file_name=server_cert,\n        server_key_file_name=server_key,\n        accepted_client_cns=None,\n        app_validator=app_validator,\n    )\n    return admin_server\n\n\nif __name__ == \"__main__\":\n    \"\"\"\n    This is the main program when starting the NVIDIA FLARE server process.\n    \"\"\"\n\n    main()\n", "path": "nvflare/private/fed/app/server/server_train.py"}]}