prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  How could I reduce number of workers?
  Could I reduce the number_of_workers?
  ---------
  I run the doccano in my machine use this code.
  ```
  doccano init
  doccano create user ***
  doccano web server --port ***
  ```
  And then I got this log: 
  ```
  Booting worker with pid: 19
  Booting worker with pid: 20
  ...
  Booting worker with pid: 157
  ```
  It run lots of worker and it took up a lot of memory. So, can I change the number_of_worker varlible. I saw the default number_of_worker= ``` multiprocessing.cpu_count()*2+1 ```. How could I change it?
  
  
  Your Environment
  ---------
  *   Operating System: Linux
  *   Python Version Used: Python38
  *   When you install doccano: 2021-11-30
  *   How did you install doccano (Heroku button etc): pip install doccano
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `backend/cli.py`
  Content:
  ```
  1 import argparse
  2 import multiprocessing
  3 import os
  4 import platform
  5 import sys
  6 from pathlib import Path
  7 
  8 import django
  9 from django.core import management
  10 
  11 from .config.celery import app
  12 
  13 DOCCANO_HOME = os.path.expanduser(os.environ.get("DOCCANO_HOME", "~/doccano"))
  14 Path(DOCCANO_HOME).mkdir(parents=True, exist_ok=True)
  15 os.environ["STANDALONE"] = "True"
  16 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
  17 os.environ.setdefault("DATABASE_URL", os.path.join(f"sqlite:///{DOCCANO_HOME}", "db.sqlite3"))
  18 os.environ.setdefault("MEDIA_ROOT", os.path.join(DOCCANO_HOME, "media"))
  19 base = os.path.abspath(os.path.dirname(__file__))
  20 sys.path.append(base)
  21 django.setup()
  22 parser = argparse.ArgumentParser(description="doccano, text annotation for machine learning practitioners.")
  23 
  24 
  25 def number_of_workers():
  26     return (multiprocessing.cpu_count() * 2) + 1
  27 
  28 
  29 def is_windows():
  30     return platform.system() == "Windows"
  31 
  32 
  33 def run_on_nix(args):
  34     import gunicorn.app.base
  35     import gunicorn.util
  36 
  37     class StandaloneApplication(gunicorn.app.base.BaseApplication):
  38         def __init__(self, options=None):
  39             self.options = options or {}
  40             super().__init__()
  41 
  42         def load_config(self):
  43             config = {
  44                 key: value for key, value in self.options.items() if key in self.cfg.settings and value is not None
  45             }
  46             for key, value in config.items():
  47                 self.cfg.set(key.lower(), value)
  48 
  49         def load(self):
  50             return gunicorn.util.import_app("config.wsgi")
  51 
  52     options = {
  53         "bind": "%s:%s" % ("0.0.0.0", args.port),
  54         "workers": number_of_workers(),
  55         "chdir": base,
  56         "capture_output": True,
  57         "loglevel": "debug",
  58     }
  59     StandaloneApplication(options).run()
  60 
  61 
  62 def run_on_windows(args):
  63     from waitress import serve
  64 
  65     from config.wsgi import application
  66 
  67     serve(application, port=args.port)
  68 
  69 
  70 def command_db_init(args):
  71     print("Setup Database.")
  72     management.call_command("wait_for_db")
  73     management.call_command("migrate")
  74     management.call_command("create_roles")
  75 
  76 
  77 def command_user_create(args):
  78     print("Create admin user.")
  79     management.call_command(
  80         "create_admin", "--noinput", username=args.username, password=args.password, email=args.email
  81     )
  82 
  83 
  84 def command_migrate(args):
  85     print("Start migration.")
  86     management.call_command("migrate")
  87 
  88 
  89 def command_run_webserver(args):
  90     print(f"Starting server with port {args.port}.")
  91     if is_windows():
  92         run_on_windows(args)
  93     else:
  94         run_on_nix(args)
  95 
  96 
  97 def command_run_task_queue(args):
  98     print("Starting task queue.")
  99     argv = [
  100         "--app=config",
  101         "--workdir={}".format(base),
  102         "worker",
  103         "--loglevel=info",
  104         "--concurrency={}".format(args.concurrency),
  105     ]
  106     if is_windows():
  107         argv.append("--pool=solo")
  108     app.worker_main(argv=argv)
  109 
  110 
  111 def command_help(args):
  112     print(parser.parse_args([args.command, "--help"]))
  113 
  114 
  115 def main():
  116     # Create a command line parser.
  117     subparsers = parser.add_subparsers()
  118 
  119     # Create a parser for db initialization.
  120     parser_init = subparsers.add_parser("init", help="see `init -h`")
  121     parser_init.set_defaults(handler=command_db_init)
  122 
  123     # Create a parser for migration.
  124     parser_migration = subparsers.add_parser("migrate", help="Updates database schema.")
  125     parser_migration.set_defaults(handler=command_migrate)
  126 
  127     # Create a parser for user creation.
  128     parser_create_user = subparsers.add_parser("createuser", help="see `createuser -h`")
  129     parser_create_user.add_argument("--username", type=str, default="admin", help="admin username")
  130     parser_create_user.add_argument("--password", type=str, default="password", help="admin password")
  131     parser_create_user.add_argument("--email", type=str, default="example@example.com", help="admin email")
  132     parser_create_user.set_defaults(handler=command_user_create)
  133 
  134     # Create a parser for web server.
  135     parser_server = subparsers.add_parser("webserver", help="see `webserver -h`")
  136     parser_server.add_argument("--port", type=int, default=8000, help="port number")
  137     parser_server.set_defaults(handler=command_run_webserver)
  138 
  139     # Create a parser for task queue.
  140     parser_queue = subparsers.add_parser("task", help="see `task -h`")
  141     parser_queue.add_argument("--concurrency", type=int, default=2, help="concurrency")
  142     parser_queue.set_defaults(handler=command_run_task_queue)
  143 
  144     # Create a parser for help.
  145     parser_help = subparsers.add_parser("help", help="see `help -h`")
  146     parser_help.add_argument("command", help="command name which help is shown")
  147     parser_help.set_defaults(handler=command_help)
  148 
  149     # Dispatch handler.
  150     args = parser.parse_args()
  151     if hasattr(args, "handler"):
  152         args.handler(args)
  153     else:
  154         # If specified unknown command, show help.
  155         parser.print_help()
  156 
  157 
  158 if __name__ == "__main__":
  159     main()
  160
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/backend/cli.py b/backend/cli.py
  --- a/backend/cli.py
  +++ b/backend/cli.py
  @@ -51,7 +51,7 @@
   
       options = {
           "bind": "%s:%s" % ("0.0.0.0", args.port),
  -        "workers": number_of_workers(),
  +        "workers": args.workers,
           "chdir": base,
           "capture_output": True,
           "loglevel": "debug",
  @@ -134,6 +134,7 @@
       # Create a parser for web server.
       parser_server = subparsers.add_parser("webserver", help="see `webserver -h`")
       parser_server.add_argument("--port", type=int, default=8000, help="port number")
  +    parser_server.add_argument("--workers", type=int, default=number_of_workers(), help="the number of workers")
       parser_server.set_defaults(handler=command_run_webserver)
   
       # Create a parser for task queue.
  
verification_info: {"golden_diff": "diff --git a/backend/cli.py b/backend/cli.py\n--- a/backend/cli.py\n+++ b/backend/cli.py\n@@ -51,7 +51,7 @@\n \n     options = {\n         \"bind\": \"%s:%s\" % (\"0.0.0.0\", args.port),\n-        \"workers\": number_of_workers(),\n+        \"workers\": args.workers,\n         \"chdir\": base,\n         \"capture_output\": True,\n         \"loglevel\": \"debug\",\n@@ -134,6 +134,7 @@\n     # Create a parser for web server.\n     parser_server = subparsers.add_parser(\"webserver\", help=\"see `webserver -h`\")\n     parser_server.add_argument(\"--port\", type=int, default=8000, help=\"port number\")\n+    parser_server.add_argument(\"--workers\", type=int, default=number_of_workers(), help=\"the number of workers\")\n     parser_server.set_defaults(handler=command_run_webserver)\n \n     # Create a parser for task queue.\n", "issue": "How could I reduce number of workers?\nCould I reduce the number_of_workers?\r\n---------\r\nI run the doccano in my machine use this code.\r\n```\r\ndoccano init\r\ndoccano create user ***\r\ndoccano web server --port ***\r\n```\r\nAnd then I got this log: \r\n```\r\nBooting worker with pid: 19\r\nBooting worker with pid: 20\r\n...\r\nBooting worker with pid: 157\r\n```\r\nIt run lots of worker and it took up a lot of memory. So, can I change the number_of_worker varlible. I saw the default number_of_worker= ``` multiprocessing.cpu_count()*2+1 ```. How could I change it?\r\n\r\n\r\nYour Environment\r\n---------\r\n*   Operating System: Linux\r\n*   Python Version Used: Python38\r\n*   When you install doccano: 2021-11-30\r\n*   How did you install doccano (Heroku button etc): pip install doccano\r\n\n", "before_files": [{"content": "import argparse\nimport multiprocessing\nimport os\nimport platform\nimport sys\nfrom pathlib import Path\n\nimport django\nfrom django.core import management\n\nfrom .config.celery import app\n\nDOCCANO_HOME = os.path.expanduser(os.environ.get(\"DOCCANO_HOME\", \"~/doccano\"))\nPath(DOCCANO_HOME).mkdir(parents=True, exist_ok=True)\nos.environ[\"STANDALONE\"] = \"True\"\nos.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"config.settings.production\")\nos.environ.setdefault(\"DATABASE_URL\", os.path.join(f\"sqlite:///{DOCCANO_HOME}\", \"db.sqlite3\"))\nos.environ.setdefault(\"MEDIA_ROOT\", os.path.join(DOCCANO_HOME, \"media\"))\nbase = os.path.abspath(os.path.dirname(__file__))\nsys.path.append(base)\ndjango.setup()\nparser = argparse.ArgumentParser(description=\"doccano, text annotation for machine learning practitioners.\")\n\n\ndef number_of_workers():\n    return (multiprocessing.cpu_count() * 2) + 1\n\n\ndef is_windows():\n    return platform.system() == \"Windows\"\n\n\ndef run_on_nix(args):\n    import gunicorn.app.base\n    import gunicorn.util\n\n    class StandaloneApplication(gunicorn.app.base.BaseApplication):\n        def __init__(self, options=None):\n            self.options = options or {}\n            super().__init__()\n\n        def load_config(self):\n            config = {\n                key: value for key, value in self.options.items() if key in self.cfg.settings and value is not None\n            }\n            for key, value in config.items():\n                self.cfg.set(key.lower(), value)\n\n        def load(self):\n            return gunicorn.util.import_app(\"config.wsgi\")\n\n    options = {\n        \"bind\": \"%s:%s\" % (\"0.0.0.0\", args.port),\n        \"workers\": number_of_workers(),\n        \"chdir\": base,\n        \"capture_output\": True,\n        \"loglevel\": \"debug\",\n    }\n    StandaloneApplication(options).run()\n\n\ndef run_on_windows(args):\n    from waitress import serve\n\n    from config.wsgi import application\n\n    serve(application, port=args.port)\n\n\ndef command_db_init(args):\n    print(\"Setup Database.\")\n    management.call_command(\"wait_for_db\")\n    management.call_command(\"migrate\")\n    management.call_command(\"create_roles\")\n\n\ndef command_user_create(args):\n    print(\"Create admin user.\")\n    management.call_command(\n        \"create_admin\", \"--noinput\", username=args.username, password=args.password, email=args.email\n    )\n\n\ndef command_migrate(args):\n    print(\"Start migration.\")\n    management.call_command(\"migrate\")\n\n\ndef command_run_webserver(args):\n    print(f\"Starting server with port {args.port}.\")\n    if is_windows():\n        run_on_windows(args)\n    else:\n        run_on_nix(args)\n\n\ndef command_run_task_queue(args):\n    print(\"Starting task queue.\")\n    argv = [\n        \"--app=config\",\n        \"--workdir={}\".format(base),\n        \"worker\",\n        \"--loglevel=info\",\n        \"--concurrency={}\".format(args.concurrency),\n    ]\n    if is_windows():\n        argv.append(\"--pool=solo\")\n    app.worker_main(argv=argv)\n\n\ndef command_help(args):\n    print(parser.parse_args([args.command, \"--help\"]))\n\n\ndef main():\n    # Create a command line parser.\n    subparsers = parser.add_subparsers()\n\n    # Create a parser for db initialization.\n    parser_init = subparsers.add_parser(\"init\", help=\"see `init -h`\")\n    parser_init.set_defaults(handler=command_db_init)\n\n    # Create a parser for migration.\n    parser_migration = subparsers.add_parser(\"migrate\", help=\"Updates database schema.\")\n    parser_migration.set_defaults(handler=command_migrate)\n\n    # Create a parser for user creation.\n    parser_create_user = subparsers.add_parser(\"createuser\", help=\"see `createuser -h`\")\n    parser_create_user.add_argument(\"--username\", type=str, default=\"admin\", help=\"admin username\")\n    parser_create_user.add_argument(\"--password\", type=str, default=\"password\", help=\"admin password\")\n    parser_create_user.add_argument(\"--email\", type=str, default=\"example@example.com\", help=\"admin email\")\n    parser_create_user.set_defaults(handler=command_user_create)\n\n    # Create a parser for web server.\n    parser_server = subparsers.add_parser(\"webserver\", help=\"see `webserver -h`\")\n    parser_server.add_argument(\"--port\", type=int, default=8000, help=\"port number\")\n    parser_server.set_defaults(handler=command_run_webserver)\n\n    # Create a parser for task queue.\n    parser_queue = subparsers.add_parser(\"task\", help=\"see `task -h`\")\n    parser_queue.add_argument(\"--concurrency\", type=int, default=2, help=\"concurrency\")\n    parser_queue.set_defaults(handler=command_run_task_queue)\n\n    # Create a parser for help.\n    parser_help = subparsers.add_parser(\"help\", help=\"see `help -h`\")\n    parser_help.add_argument(\"command\", help=\"command name which help is shown\")\n    parser_help.set_defaults(handler=command_help)\n\n    # Dispatch handler.\n    args = parser.parse_args()\n    if hasattr(args, \"handler\"):\n        args.handler(args)\n    else:\n        # If specified unknown command, show help.\n        parser.print_help()\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "backend/cli.py"}], "after_files": [{"content": "import argparse\nimport multiprocessing\nimport os\nimport platform\nimport sys\nfrom pathlib import Path\n\nimport django\nfrom django.core import management\n\nfrom .config.celery import app\n\nDOCCANO_HOME = os.path.expanduser(os.environ.get(\"DOCCANO_HOME\", \"~/doccano\"))\nPath(DOCCANO_HOME).mkdir(parents=True, exist_ok=True)\nos.environ[\"STANDALONE\"] = \"True\"\nos.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"config.settings.production\")\nos.environ.setdefault(\"DATABASE_URL\", os.path.join(f\"sqlite:///{DOCCANO_HOME}\", \"db.sqlite3\"))\nos.environ.setdefault(\"MEDIA_ROOT\", os.path.join(DOCCANO_HOME, \"media\"))\nbase = os.path.abspath(os.path.dirname(__file__))\nsys.path.append(base)\ndjango.setup()\nparser = argparse.ArgumentParser(description=\"doccano, text annotation for machine learning practitioners.\")\n\n\ndef number_of_workers():\n    return (multiprocessing.cpu_count() * 2) + 1\n\n\ndef is_windows():\n    return platform.system() == \"Windows\"\n\n\ndef run_on_nix(args):\n    import gunicorn.app.base\n    import gunicorn.util\n\n    class StandaloneApplication(gunicorn.app.base.BaseApplication):\n        def __init__(self, options=None):\n            self.options = options or {}\n            super().__init__()\n\n        def load_config(self):\n            config = {\n                key: value for key, value in self.options.items() if key in self.cfg.settings and value is not None\n            }\n            for key, value in config.items():\n                self.cfg.set(key.lower(), value)\n\n        def load(self):\n            return gunicorn.util.import_app(\"config.wsgi\")\n\n    options = {\n        \"bind\": \"%s:%s\" % (\"0.0.0.0\", args.port),\n        \"workers\": args.workers,\n        \"chdir\": base,\n        \"capture_output\": True,\n        \"loglevel\": \"debug\",\n    }\n    StandaloneApplication(options).run()\n\n\ndef run_on_windows(args):\n    from waitress import serve\n\n    from config.wsgi import application\n\n    serve(application, port=args.port)\n\n\ndef command_db_init(args):\n    print(\"Setup Database.\")\n    management.call_command(\"wait_for_db\")\n    management.call_command(\"migrate\")\n    management.call_command(\"create_roles\")\n\n\ndef command_user_create(args):\n    print(\"Create admin user.\")\n    management.call_command(\n        \"create_admin\", \"--noinput\", username=args.username, password=args.password, email=args.email\n    )\n\n\ndef command_migrate(args):\n    print(\"Start migration.\")\n    management.call_command(\"migrate\")\n\n\ndef command_run_webserver(args):\n    print(f\"Starting server with port {args.port}.\")\n    if is_windows():\n        run_on_windows(args)\n    else:\n        run_on_nix(args)\n\n\ndef command_run_task_queue(args):\n    print(\"Starting task queue.\")\n    argv = [\n        \"--app=config\",\n        \"--workdir={}\".format(base),\n        \"worker\",\n        \"--loglevel=info\",\n        \"--concurrency={}\".format(args.concurrency),\n    ]\n    if is_windows():\n        argv.append(\"--pool=solo\")\n    app.worker_main(argv=argv)\n\n\ndef command_help(args):\n    print(parser.parse_args([args.command, \"--help\"]))\n\n\ndef main():\n    # Create a command line parser.\n    subparsers = parser.add_subparsers()\n\n    # Create a parser for db initialization.\n    parser_init = subparsers.add_parser(\"init\", help=\"see `init -h`\")\n    parser_init.set_defaults(handler=command_db_init)\n\n    # Create a parser for migration.\n    parser_migration = subparsers.add_parser(\"migrate\", help=\"Updates database schema.\")\n    parser_migration.set_defaults(handler=command_migrate)\n\n    # Create a parser for user creation.\n    parser_create_user = subparsers.add_parser(\"createuser\", help=\"see `createuser -h`\")\n    parser_create_user.add_argument(\"--username\", type=str, default=\"admin\", help=\"admin username\")\n    parser_create_user.add_argument(\"--password\", type=str, default=\"password\", help=\"admin password\")\n    parser_create_user.add_argument(\"--email\", type=str, default=\"example@example.com\", help=\"admin email\")\n    parser_create_user.set_defaults(handler=command_user_create)\n\n    # Create a parser for web server.\n    parser_server = subparsers.add_parser(\"webserver\", help=\"see `webserver -h`\")\n    parser_server.add_argument(\"--port\", type=int, default=8000, help=\"port number\")\n    parser_server.add_argument(\"--workers\", type=int, default=number_of_workers(), help=\"the number of workers\")\n    parser_server.set_defaults(handler=command_run_webserver)\n\n    # Create a parser for task queue.\n    parser_queue = subparsers.add_parser(\"task\", help=\"see `task -h`\")\n    parser_queue.add_argument(\"--concurrency\", type=int, default=2, help=\"concurrency\")\n    parser_queue.set_defaults(handler=command_run_task_queue)\n\n    # Create a parser for help.\n    parser_help = subparsers.add_parser(\"help\", help=\"see `help -h`\")\n    parser_help.add_argument(\"command\", help=\"command name which help is shown\")\n    parser_help.set_defaults(handler=command_help)\n\n    # Dispatch handler.\n    args = parser.parse_args()\n    if hasattr(args, \"handler\"):\n        args.handler(args)\n    else:\n        # If specified unknown command, show help.\n        parser.print_help()\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "backend/cli.py"}]}