#72 Adding an Environment

Rails提供了三种预设环境:开发、测试及生产,但开发者并不局限于此。本篇介绍如何自定义环境,通过示例展示了如何设置staging阶段环境的数据库配置,并进行数据库迁移。
Rails comes with three environments: development, test, and production. But, you aren't restricted to just these. You can add your own! See how in this episode.
# database.yml
staging:
adapter: mysql
database: store_staging
user: root
password:
host: localhost

# environments/staging.rb
config.log_level = :debug

mysqladmin create store_staging -u root -p
rake db:migrate RAILS_ENV=staging
script/server -e staging
Downloading and Extracting Packages expat-2.7.1 | 371 KB | ####################################################################################################################################### | 100% vc14_runtime-14.44.3 | 1.5 MB | ####################################################################################################################################### | 100% zlib-1.2.13 | 158 KB | ####################################################################################################################################### | 100% vs2015_runtime-14.44 | 19 KB | ####################################################################################################################################### | 100% wheel-0.45.1 | 138 KB | ####################################################################################################################################### | 100% pip-25.1 | 1.4 MB | ####################################################################################################################################### | 100% openssl-3.0.17 | 8.0 MB | ####################################################################################################################################### | 100% python-3.9.23 | 17.4 MB | ####################################################################################################################################### | 100% setuptools-78.1.1 | 1.7 MB | ####################################################################################################################################### | 100% ca-certificates-2025 | 166 KB | ####################################################################################################################################### | 100% sqlite-3.50.2 | 1.4 MB | ####################################################################################################################################### | 100% xz-5.6.4 | 283 KB | ####################################################################################################################################### | 100% libffi-3.4.4 | 152 KB | ####################################################################################################################################### | 100% tzdata-2025b | 123 KB | ####################################################################################################################################### | 100% tk-8.6.15 | 3.7 MB | ##################################################################################################################################################### | 100% vc-14.3 | 19 KB | ##################################################################################################################################################### | 100% bzip2-1.0.8 | 110 KB | ##################################################################################################################################################### | 100% ucrt-10.0.22621.0 | 1.2 MB | ##################################################################################################################################################### | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done Collecting PyQt5==5.15.11 (from -r C:\Users\lry20\source\repos\consaltant\requirements.txt (line 1)) Using cached PyQt5-5.15.11-cp38-abi3-win_amd64.whl.metadata (2.1 kB) Collecting PyQt5_sip==12.17.0 (from -r C:\Users\lry20\source\repos\consaltant\requirements.txt (line 2)) Downloading PyQt5_sip-12.17.0-cp39-cp39-win_amd64.whl.metadata (492 bytes) Collecting Requests==2.32.5 (from -r C:\Users\lry20\source\repos\consaltant\requirements.txt (line 3)) Downloading requests-2.32.5-py3-none-any.whl.metadata (4.9 kB) Collecting PyQt5-Qt5<5.16.0,>=5.15.2 (from PyQt5==5.15.11->-r C:\Users\lry20\source\repos\consaltant\requirements.txt (line 1)) Using cached PyQt5_Qt5-5.15.2-py3-none-win_amd64.whl.metadata (552 bytes) Collecting charset_normalizer<4,>=2 (from Requests==2.32.5->-r C:\Users\lry20\source\repos\consaltant\requirements.txt (line 3)) Downloading charset_normalizer-3.4.3-cp39-cp39-win_amd64.whl.metadata (37 kB) Collecting idna<4,>=2.5 (from Requests==2.32.5->-r C:\Users\lry20\source\repos\consaltant\requirements.txt (line 3)) Using cached idna-3.10-py3-none-any.whl.metadata (10 kB) Collecting urllib3<3,>=1.21.1 (from Requests==2.32.5->-r C:\Users\lry20\source\repos\consaltant\requirements.txt (line 3)) Using cached urllib3-2.5.0-py3-none-any.whl.metadata (6.5 kB) Collecting certifi>=2017.4.17 (from Requests==2.32.5->-r C:\Users\lry20\source\repos\consaltant\requirements.txt (line 3)) Downloading certifi-2025.8.3-py3-none-any.whl.metadata (2.4 kB) Using cached PyQt5-5.15.11-cp38-abi3-win_amd64.whl (6.9 MB) Downloading PyQt5_sip-12.17.0-cp39-cp39-win_amd64.whl (59 kB) Downloading requests-2.32.5-py3-none-any.whl (64 kB) Downloading charset_normalizer-3.4.3-cp39-cp39-win_amd64.whl (107 kB) Using cached idna-3.10-py3-none-any.whl (70 kB) Using cached PyQt5_Qt5-5.15.2-py3-none-win_amd64.whl (50.1 MB) Using cached urllib3-2.5.0-py3-none-any.whl (129 kB) Downloading certifi-2025.8.3-py3-none-any.whl (161 kB) Installing collected packages: PyQt5-Qt5, urllib3, PyQt5_sip, idna, charset_normalizer, certifi, Requests, PyQt5 ━━━━━━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━ 3/8 [idna] WARNING: The script normalizer.exe is installed in &#39;C:\Users\lry20\Anaconda3\envs\my_project_env\Scripts&#39; which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╺━━━━ 7/8 [PyQt5] WARNING: The scripts pylupdate5.exe, pyrcc5.exe and pyuic5.exe are installed in &#39;C:\Users\lry20\Anaconda3\envs\my_project_env\Scripts&#39; which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed PyQt5-5.15.11 PyQt5-Qt5-5.15.2 PyQt5_sip-12.17.0 Requests-2.32.5 certifi-2025.8.3 charset_normalizer-3.4.3 idna-3.10 urllib3-2.5.0 # # To activate this environment, use: # > activate my_project_env # # To deactivate an active environment, use: # > deactivate # # * for power-users using bash, you must source #
08-26
(base) guanxiong@guanxiong-virtual-machine:~/isaacgym/python$ conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main (base) guanxiong@guanxiong-virtual-machine:~/isaacgym/python$ conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free (base) guanxiong@guanxiong-virtual-machine:~/isaacgym/python$ conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch (base) guanxiong@guanxiong-virtual-machine:~/isaacgym/python$ conda config --set show_channel_urls yes (base) guanxiong@guanxiong-virtual-machine:~/isaacgym/python$ conda config --set restore_free_channel true (base) guanxiong@guanxiong-virtual-machine:~/isaacgym/python$ conda clean -i -p -y Will remove 1 index cache(s). Will remove 44 (1009.4 MB) package(s). (base) guanxiong@guanxiong-virtual-machine:~/isaacgym/python$ conda env create -f rlgpu_conda_env.yml -n rlgpu /home/guanxiong/miniconda3/lib/python3.13/site-packages/conda/base/context.py:938: FutureWarning: Adding the &#39;free&#39; channel using `restore_free_channel` config is deprecated and will be removed in 25.9. See https://docs.conda.io/projects/conda/en/stable/user-guide/configuration/free-channel.html for more details. deprecated.topic( /home/guanxiong/miniconda3/lib/python3.13/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host &#39;repo.anaconda.com&#39;. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings warnings.warn( 2 channel Terms of Service accepted Channels: - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free - defaults Platform: linux-64 Collecting package metadata (repodata.json): done Solving environment: done ==> WARNING: A newer version of conda exists. <== current version: 25.5.1 latest version: 25.7.0 Please update conda by running $ conda update -n base -c defaults conda Downloading and Extracting Packages: Preparing transaction: done Verifying transaction: done Executing transaction: \ By downloading and using the CUDA Toolkit conda packages, you accept the terms and conditions of the CUDA End User License Agreement (EULA): https://docs.nvidia.com/cuda/eula/index.html done # # To activate this environment, use # # $ conda activate rlgpu # # To deactivate an active environment, use # # $ conda deactivate
08-23
11-21
# Configuration file for notebook. c = get_config() #noqa #------------------------------------------------------------------------------ # Application(SingletonConfigurable) configuration #------------------------------------------------------------------------------ ## This is an application. ## The date format used by logging formatters for %(asctime)s # Default: &#39;%Y-%m-%d %H:%M:%S&#39; # c.Application.log_datefmt = &#39;%Y-%m-%d %H:%M:%S&#39; ## The Logging format template # Default: &#39;[%(name)s]%(highlevel)s %(message)s&#39; # c.Application.log_format = &#39;[%(name)s]%(highlevel)s %(message)s&#39; ## Set the log level by value or name. # Choices: any of [0, 10, 20, 30, 40, 50, &#39;DEBUG&#39;, &#39;INFO&#39;, &#39;WARN&#39;, &#39;ERROR&#39;, &#39;CRITICAL&#39;] # Default: 30 # c.Application.log_level = 30 ## Configure additional log handlers. # # The default stderr logs handler is configured by the log_level, log_datefmt # and log_format settings. # # This configuration can be used to configure additional handlers (e.g. to # output the log to a file) or for finer control over the default handlers. # # If provided this should be a logging configuration dictionary, for more # information see: # https://docs.python.org/3/library/logging.config.html#logging-config- # dictschema # # This dictionary is merged with the base logging configuration which defines # the following: # # * A logging formatter intended for interactive use called # ``console``. # * A logging handler that writes to stderr called # ``console`` which uses the formatter ``console``. # * A logger with the name of this application set to ``DEBUG`` # level. # # This example adds a new handler that writes to a file: # # .. code-block:: python # # c.Application.logging_config = { # &#39;handlers&#39;: { # &#39;file&#39;: { # &#39;class&#39;: &#39;logging.FileHandler&#39;, # &#39;level&#39;: &#39;DEBUG&#39;, # &#39;filename&#39;: &#39;<path/to/file>&#39;, # } # }, # &#39;loggers&#39;: { # &#39;<application-name>&#39;: { # &#39;level&#39;: &#39;DEBUG&#39;, # # NOTE: if you don&#39;t list the default "console" # # handler here then it will be disabled # &#39;handlers&#39;: [&#39;console&#39;, &#39;file&#39;], # }, # } # } # Default: {} # c.Application.logging_config = {} ## Instead of starting the Application, dump configuration to stdout # Default: False # c.Application.show_config = False ## Instead of starting the Application, dump configuration to stdout (as JSON) # Default: False # c.Application.show_config_json = False #------------------------------------------------------------------------------ # JupyterApp(Application) configuration #------------------------------------------------------------------------------ ## Base class for Jupyter applications ## Answer yes to any prompts. # Default: False # c.JupyterApp.answer_yes = False ## Full path of a config file. # Default: &#39;&#39; # c.JupyterApp.config_file = &#39;&#39; ## Specify a config file to load. # Default: &#39;&#39; # c.JupyterApp.config_file_name = &#39;&#39; ## Generate default config file. # Default: False # c.JupyterApp.generate_config = False ## The date format used by logging formatters for %(asctime)s # See also: Application.log_datefmt # c.JupyterApp.log_datefmt = &#39;%Y-%m-%d %H:%M:%S&#39; ## The Logging format template # See also: Application.log_format # c.JupyterApp.log_format = &#39;[%(name)s]%(highlevel)s %(message)s&#39; ## Set the log level by value or name. # See also: Application.log_level # c.JupyterApp.log_level = 30 ## # See also: Application.logging_config # c.JupyterApp.logging_config = {} ## Instead of starting the Application, dump configuration to stdout # See also: Application.show_config # c.JupyterApp.show_config = False ## Instead of starting the Application, dump configuration to stdout (as JSON) # See also: Application.show_config_json # c.JupyterApp.show_config_json = False #------------------------------------------------------------------------------ # ExtensionApp(JupyterApp) configuration #------------------------------------------------------------------------------ ## Base class for configurable Jupyter Server Extension Applications. # # ExtensionApp subclasses can be initialized two ways: # # - Extension is listed as a jpserver_extension, and ServerApp calls # its load_jupyter_server_extension classmethod. This is the # classic way of loading a server extension. # # - Extension is launched directly by calling its `launch_instance` # class method. This method can be set as a entry_point in # the extensions setup.py. ## Answer yes to any prompts. # See also: JupyterApp.answer_yes # c.ExtensionApp.answer_yes = False ## Full path of a config file. # See also: JupyterApp.config_file # c.ExtensionApp.config_file = &#39;&#39; ## Specify a config file to load. # See also: JupyterApp.config_file_name # c.ExtensionApp.config_file_name = &#39;&#39; # Default: &#39;&#39; # c.ExtensionApp.default_url = &#39;&#39; ## Generate default config file. # See also: JupyterApp.generate_config # c.ExtensionApp.generate_config = False ## Handlers appended to the server. # Default: [] # c.ExtensionApp.handlers = [] ## The date format used by logging formatters for %(asctime)s # See also: Application.log_datefmt # c.ExtensionApp.log_datefmt = &#39;%Y-%m-%d %H:%M:%S&#39; ## The Logging format template # See also: Application.log_format # c.ExtensionApp.log_format = &#39;[%(name)s]%(highlevel)s %(message)s&#39; ## Set the log level by value or name. # See also: Application.log_level # c.ExtensionApp.log_level = 30 ## # See also: Application.logging_config # c.ExtensionApp.logging_config = {} ## Whether to open in a browser after starting. # The specific browser used is platform dependent and # determined by the python standard library `webbrowser` # module, unless it is overridden using the --browser # (ServerApp.browser) configuration option. # Default: False # c.ExtensionApp.open_browser = False ## Settings that will passed to the server. # Default: {} # c.ExtensionApp.settings = {} ## Instead of starting the Application, dump configuration to stdout # See also: Application.show_config # c.ExtensionApp.show_config = False ## Instead of starting the Application, dump configuration to stdout (as JSON) # See also: Application.show_config_json # c.ExtensionApp.show_config_json = False ## paths to search for serving static files. # # This allows adding javascript/css to be available from the notebook server machine, # or overriding individual files in the IPython # Default: [] # c.ExtensionApp.static_paths = [] ## Url where the static assets for the extension are served. # Default: &#39;&#39; # c.ExtensionApp.static_url_prefix = &#39;&#39; ## Paths to search for serving jinja templates. # # Can be used to override templates from notebook.templates. # Default: [] # c.ExtensionApp.template_paths = [] #------------------------------------------------------------------------------ # LabServerApp(ExtensionApp) configuration #------------------------------------------------------------------------------ ## A Lab Server Application that runs out-of-the-box ## "A list of comma-separated URIs to get the allowed extensions list # # .. versionchanged:: 2.0.0 # `LabServerApp.whitetlist_uris` renamed to `allowed_extensions_uris` # Default: &#39;&#39; # c.LabServerApp.allowed_extensions_uris = &#39;&#39; ## Answer yes to any prompts. # See also: JupyterApp.answer_yes # c.LabServerApp.answer_yes = False ## The application settings directory. # Default: &#39;&#39; # c.LabServerApp.app_settings_dir = &#39;&#39; ## The url path for the application. # Default: &#39;/lab&#39; # c.LabServerApp.app_url = &#39;/lab&#39; ## Deprecated, use `LabServerApp.blocked_extensions_uris` # Default: &#39;&#39; # c.LabServerApp.blacklist_uris = &#39;&#39; ## A list of comma-separated URIs to get the blocked extensions list # # .. versionchanged:: 2.0.0 # `LabServerApp.blacklist_uris` renamed to `blocked_extensions_uris` # Default: &#39;&#39; # c.LabServerApp.blocked_extensions_uris = &#39;&#39; ## Whether to cache files on the server. This should be `True` except in dev # mode. # Default: True # c.LabServerApp.cache_files = True ## Full path of a config file. # See also: JupyterApp.config_file # c.LabServerApp.config_file = &#39;&#39; ## Specify a config file to load. # See also: JupyterApp.config_file_name # c.LabServerApp.config_file_name = &#39;&#39; ## Whether getting a relative (False) or absolute (True) path when copying a # path. # Default: False # c.LabServerApp.copy_absolute_path = False ## Extra paths to look for federated JupyterLab extensions # Default: [] # c.LabServerApp.extra_labextensions_path = [] ## Generate default config file. # See also: JupyterApp.generate_config # c.LabServerApp.generate_config = False ## Handlers appended to the server. # See also: ExtensionApp.handlers # c.LabServerApp.handlers = [] ## Options to pass to the jinja2 environment for this # Default: {} # c.LabServerApp.jinja2_options = {} ## The standard paths to look in for federated JupyterLab extensions # Default: [] # c.LabServerApp.labextensions_path = [] ## The url for federated JupyterLab extensions # Default: &#39;&#39; # c.LabServerApp.labextensions_url = &#39;&#39; ## The interval delay in seconds to refresh the lists # Default: 3600 # c.LabServerApp.listings_refresh_seconds = 3600 ## The optional kwargs to use for the listings HTTP requests as # described on https://2.python-requests.org/en/v2.7.0/api/#requests.request # Default: {} # c.LabServerApp.listings_request_options = {} ## The listings url. # Default: &#39;&#39; # c.LabServerApp.listings_url = &#39;&#39; ## The date format used by logging formatters for %(asctime)s # See also: Application.log_datefmt # c.LabServerApp.log_datefmt = &#39;%Y-%m-%d %H:%M:%S&#39; ## The Logging format template # See also: Application.log_format # c.LabServerApp.log_format = &#39;[%(name)s]%(highlevel)s %(message)s&#39; ## Set the log level by value or name. # See also: Application.log_level # c.LabServerApp.log_level = 30 ## # See also: Application.logging_config # c.LabServerApp.logging_config = {} ## Whether a notebook should start a kernel automatically. # Default: True # c.LabServerApp.notebook_starts_kernel = True ## Whether to open in a browser after starting. # See also: ExtensionApp.open_browser # c.LabServerApp.open_browser = False ## The optional location of the settings schemas directory. If given, a handler # will be added for settings. # Default: &#39;&#39; # c.LabServerApp.schemas_dir = &#39;&#39; ## Settings that will passed to the server. # See also: ExtensionApp.settings # c.LabServerApp.settings = {} ## The url path of the settings handler. # Default: &#39;&#39; # c.LabServerApp.settings_url = &#39;&#39; ## Instead of starting the Application, dump configuration to stdout # See also: Application.show_config # c.LabServerApp.show_config = False ## Instead of starting the Application, dump configuration to stdout (as JSON) # See also: Application.show_config_json # c.LabServerApp.show_config_json = False ## The optional location of local static files. If given, a static file handler # will be added. # Default: &#39;&#39; # c.LabServerApp.static_dir = &#39;&#39; ## paths to search for serving static files. # See also: ExtensionApp.static_paths # c.LabServerApp.static_paths = [] ## Url where the static assets for the extension are served. # See also: ExtensionApp.static_url_prefix # c.LabServerApp.static_url_prefix = &#39;&#39; ## Paths to search for serving jinja templates. # See also: ExtensionApp.template_paths # c.LabServerApp.template_paths = [] ## The application templates directory. # Default: &#39;&#39; # c.LabServerApp.templates_dir = &#39;&#39; ## The optional location of the themes directory. If given, a handler will be # added for themes. # Default: &#39;&#39; # c.LabServerApp.themes_dir = &#39;&#39; ## The theme url. # Default: &#39;&#39; # c.LabServerApp.themes_url = &#39;&#39; ## The url path of the translations handler. # Default: &#39;&#39; # c.LabServerApp.translations_api_url = &#39;&#39; ## The url path of the tree handler. # Default: &#39;&#39; # c.LabServerApp.tree_url = &#39;&#39; ## The optional location of the user settings directory. # Default: &#39;&#39; # c.LabServerApp.user_settings_dir = &#39;&#39; ## Deprecated, use `LabServerApp.allowed_extensions_uris` # Default: &#39;&#39; # c.LabServerApp.whitelist_uris = &#39;&#39; ## The url path of the workspaces API. # Default: &#39;&#39; # c.LabServerApp.workspaces_api_url = &#39;&#39; ## The optional location of the saved workspaces directory. If given, a handler # will be added for workspaces. # Default: &#39;&#39; # c.LabServerApp.workspaces_dir = &#39;&#39; #------------------------------------------------------------------------------ # JupyterNotebookApp(LabServerApp) configuration #------------------------------------------------------------------------------ ## The notebook server extension app. ## # See also: LabServerApp.allowed_extensions_uris # c.JupyterNotebookApp.allowed_extensions_uris = &#39;&#39; ## Answer yes to any prompts. # See also: JupyterApp.answer_yes # c.JupyterNotebookApp.answer_yes = False ## The application settings directory. # Default: &#39;&#39; # c.JupyterNotebookApp.app_settings_dir = &#39;&#39; ## The url path for the application. # Default: &#39;/lab&#39; # c.JupyterNotebookApp.app_url = &#39;/lab&#39; ## Deprecated, use `LabServerApp.blocked_extensions_uris` # See also: LabServerApp.blacklist_uris # c.JupyterNotebookApp.blacklist_uris = &#39;&#39; ## # See also: LabServerApp.blocked_extensions_uris # c.JupyterNotebookApp.blocked_extensions_uris = &#39;&#39; ## Whether to cache files on the server. This should be `True` except in dev # mode. # Default: True # c.JupyterNotebookApp.cache_files = True ## Full path of a config file. # See also: JupyterApp.config_file # c.JupyterNotebookApp.config_file = &#39;&#39; ## Specify a config file to load. # See also: JupyterApp.config_file_name # c.JupyterNotebookApp.config_file_name = &#39;&#39; ## Whether getting a relative (False) or absolute (True) path when copying a # path. # Default: False # c.JupyterNotebookApp.copy_absolute_path = False ## Whether custom CSS is loaded on the page. # Defaults to True and custom CSS is loaded. # Default: True # c.JupyterNotebookApp.custom_css = True ## The default URL to redirect to from `/` # Default: &#39;/tree&#39; # c.JupyterNotebookApp.default_url = &#39;/tree&#39; ## Whether to expose the global app instance to browser via window.jupyterapp # Default: False # c.JupyterNotebookApp.expose_app_in_browser = False ## Extra paths to look for federated JupyterLab extensions # Default: [] # c.JupyterNotebookApp.extra_labextensions_path = [] ## Generate default config file. # See also: JupyterApp.generate_config # c.JupyterNotebookApp.generate_config = False ## Handlers appended to the server. # See also: ExtensionApp.handlers # c.JupyterNotebookApp.handlers = [] ## Options to pass to the jinja2 environment for this # Default: {} # c.JupyterNotebookApp.jinja2_options = {} ## The standard paths to look in for federated JupyterLab extensions # Default: [] # c.JupyterNotebookApp.labextensions_path = [] ## The url for federated JupyterLab extensions # Default: &#39;&#39; # c.JupyterNotebookApp.labextensions_url = &#39;&#39; ## The interval delay in seconds to refresh the lists # See also: LabServerApp.listings_refresh_seconds # c.JupyterNotebookApp.listings_refresh_seconds = 3600 ## The optional kwargs to use for the listings HTTP requests as # described on https://2.python-requests.org/en/v2.7.0/api/#requests.request # See also: LabServerApp.listings_request_options # c.JupyterNotebookApp.listings_request_options = {} ## The listings url. # Default: &#39;&#39; # c.JupyterNotebookApp.listings_url = &#39;&#39; ## The date format used by logging formatters for %(asctime)s # See also: Application.log_datefmt # c.JupyterNotebookApp.log_datefmt = &#39;%Y-%m-%d %H:%M:%S&#39; ## The Logging format template # See also: Application.log_format # c.JupyterNotebookApp.log_format = &#39;[%(name)s]%(highlevel)s %(message)s&#39; ## Set the log level by value or name. # See also: Application.log_level # c.JupyterNotebookApp.log_level = 30 ## # See also: Application.logging_config # c.JupyterNotebookApp.logging_config = {} ## Whether a notebook should start a kernel automatically. # Default: True # c.JupyterNotebookApp.notebook_starts_kernel = True ## Whether to open in a browser after starting. # See also: ExtensionApp.open_browser # c.JupyterNotebookApp.open_browser = False ## The optional location of the settings schemas directory. If given, a handler # will be added for settings. # Default: &#39;&#39; # c.JupyterNotebookApp.schemas_dir = &#39;&#39; ## Settings that will passed to the server. # See also: ExtensionApp.settings # c.JupyterNotebookApp.settings = {} ## The url path of the settings handler. # Default: &#39;&#39; # c.JupyterNotebookApp.settings_url = &#39;&#39; ## Instead of starting the Application, dump configuration to stdout # See also: Application.show_config # c.JupyterNotebookApp.show_config = False ## Instead of starting the Application, dump configuration to stdout (as JSON) # See also: Application.show_config_json # c.JupyterNotebookApp.show_config_json = False ## The optional location of local static files. If given, a static file handler # will be added. # Default: &#39;&#39; # c.JupyterNotebookApp.static_dir = &#39;&#39; ## paths to search for serving static files. # See also: ExtensionApp.static_paths # c.JupyterNotebookApp.static_paths = [] ## Url where the static assets for the extension are served. # See also: ExtensionApp.static_url_prefix # c.JupyterNotebookApp.static_url_prefix = &#39;&#39; ## Paths to search for serving jinja templates. # See also: ExtensionApp.template_paths # c.JupyterNotebookApp.template_paths = [] ## The application templates directory. # Default: &#39;&#39; # c.JupyterNotebookApp.templates_dir = &#39;&#39; ## The optional location of the themes directory. If given, a handler will be # added for themes. # Default: &#39;&#39; # c.JupyterNotebookApp.themes_dir = &#39;&#39; ## The theme url. # Default: &#39;&#39; # c.JupyterNotebookApp.themes_url = &#39;&#39; ## The url path of the translations handler. # Default: &#39;&#39; # c.JupyterNotebookApp.translations_api_url = &#39;&#39; ## The url path of the tree handler. # Default: &#39;&#39; # c.JupyterNotebookApp.tree_url = &#39;&#39; ## The optional location of the user settings directory. # Default: &#39;&#39; # c.JupyterNotebookApp.user_settings_dir = &#39;&#39; ## Deprecated, use `LabServerApp.allowed_extensions_uris` # See also: LabServerApp.whitelist_uris # c.JupyterNotebookApp.whitelist_uris = &#39;&#39; ## The url path of the workspaces API. # Default: &#39;&#39; # c.JupyterNotebookApp.workspaces_api_url = &#39;&#39; ## The optional location of the saved workspaces directory. If given, a handler # will be added for workspaces. # Default: &#39;&#39; # c.JupyterNotebookApp.workspaces_dir = &#39;&#39; #------------------------------------------------------------------------------ # ServerApp(JupyterApp) configuration #------------------------------------------------------------------------------ ## The Jupyter Server application class. ## Set the Access-Control-Allow-Credentials: true header # Default: False # c.ServerApp.allow_credentials = False ## Set the Access-Control-Allow-Origin header # # Use &#39;*&#39; to allow any origin to access your server. # # Takes precedence over allow_origin_pat. # Default: &#39;&#39; # c.ServerApp.allow_origin = &#39;&#39; ## Use a regular expression for the Access-Control-Allow-Origin header # # Requests from an origin matching the expression will get replies with: # # Access-Control-Allow-Origin: origin # # where `origin` is the origin of the request. # # Ignored if allow_origin is set. # Default: &#39;&#39; # c.ServerApp.allow_origin_pat = &#39;&#39; ## DEPRECATED in 2.0. Use PasswordIdentityProvider.allow_password_change # Default: True # c.ServerApp.allow_password_change = True ## Allow requests where the Host header doesn&#39;t point to a local server # # By default, requests get a 403 forbidden response if the &#39;Host&#39; header # shows that the browser thinks it&#39;s on a non-local domain. # Setting this option to True disables this check. # # This protects against &#39;DNS rebinding&#39; attacks, where a remote web server # serves you a page and then changes its DNS to send later requests to a # local IP, bypassing same-origin checks. # # Local IP addresses (such as 127.0.0.1 and ::1) are allowed as local, # along with hostnames configured in local_hostnames. # Default: False # c.ServerApp.allow_remote_access = False ## Whether to allow the user to run the server as root. # Default: False # c.ServerApp.allow_root = False ## Answer yes to any prompts. # See also: JupyterApp.answer_yes # c.ServerApp.answer_yes = False ## " # Require authentication to access prometheus metrics. # Default: True # c.ServerApp.authenticate_prometheus = True ## The authorizer class to use. # Default: &#39;jupyter_server.auth.authorizer.AllowAllAuthorizer&#39; # c.ServerApp.authorizer_class = &#39;jupyter_server.auth.authorizer.AllowAllAuthorizer&#39; ## Reload the webapp when changes are made to any Python src files. # Default: False # c.ServerApp.autoreload = False ## The base URL for the Jupyter server. # # Leading and trailing slashes can be omitted, # and will automatically be added. # Default: &#39;/&#39; # c.ServerApp.base_url = &#39;/&#39; ## Specify what command to use to invoke a web # browser when starting the server. If not specified, the # default browser will be determined by the `webbrowser` # standard library module, which allows setting of the # BROWSER environment variable to override it. # Default: &#39;&#39; # c.ServerApp.browser = &#39;&#39; ## The full path to an SSL/TLS certificate file. # Default: &#39;&#39; # c.ServerApp.certfile = &#39;&#39; ## The full path to a certificate authority certificate for SSL/TLS client # authentication. # Default: &#39;&#39; # c.ServerApp.client_ca = &#39;&#39; ## Full path of a config file. # See also: JupyterApp.config_file # c.ServerApp.config_file = &#39;&#39; ## Specify a config file to load. # See also: JupyterApp.config_file_name # c.ServerApp.config_file_name = &#39;&#39; ## The config manager class to use # Default: &#39;jupyter_server.services.config.manager.ConfigManager&#39; # c.ServerApp.config_manager_class = &#39;jupyter_server.services.config.manager.ConfigManager&#39; ## The content manager class to use. # Default: &#39;jupyter_server.services.contents.largefilemanager.AsyncLargeFileManager&#39; # c.ServerApp.contents_manager_class = &#39;jupyter_server.services.contents.largefilemanager.AsyncLargeFileManager&#39; ## DEPRECATED. Use IdentityProvider.cookie_options # Default: {} # c.ServerApp.cookie_options = {} ## The random bytes used to secure cookies. # By default this is a new random number every time you start the server. # Set it to a value in a config file to enable logins to persist across server sessions. # # Note: Cookie secrets should be kept private, do not share config files with # cookie_secret stored in plaintext (you can read the value from a file). # Default: b&#39;&#39; # c.ServerApp.cookie_secret = b&#39;&#39; ## The file where the cookie secret is stored. # Default: &#39;&#39; # c.ServerApp.cookie_secret_file = &#39;&#39; ## Override URL shown to users. # # Replace actual URL, including protocol, address, port and base URL, # with the given value when displaying URL to the users. Do not change # the actual connection URL. If authentication token is enabled, the # token is added to the custom URL automatically. # # This option is intended to be used when the URL to display to the user # cannot be determined reliably by the Jupyter server (proxified # or containerized setups for example). # Default: &#39;&#39; # c.ServerApp.custom_display_url = &#39;&#39; ## The default URL to redirect to from `/` # Default: &#39;/&#39; # c.ServerApp.default_url = &#39;/&#39; ## Disable cross-site-request-forgery protection # # Jupyter server includes protection from cross-site request forgeries, # requiring API requests to either: # # - originate from pages served by this server (validated with XSRF cookie and token), or # - authenticate with a token # # Some anonymous compute resources still desire the ability to run code, # completely without authentication. # These services can disable all authentication and security checks, # with the full knowledge of what that implies. # Default: False # c.ServerApp.disable_check_xsrf = False ## handlers that should be loaded at higher priority than the default services # Default: [] # c.ServerApp.extra_services = [] ## Extra paths to search for serving static files. # # This allows adding javascript/css to be available from the Jupyter server machine, # or overriding individual files in the IPython # Default: [] # c.ServerApp.extra_static_paths = [] ## Extra paths to search for serving jinja templates. # # Can be used to override templates from jupyter_server.templates. # Default: [] # c.ServerApp.extra_template_paths = [] ## Open the named file when the application is launched. # Default: &#39;&#39; # c.ServerApp.file_to_run = &#39;&#39; ## The URL prefix where files are opened directly. # Default: &#39;notebooks&#39; # c.ServerApp.file_url_prefix = &#39;notebooks&#39; ## Generate default config file. # See also: JupyterApp.generate_config # c.ServerApp.generate_config = False ## DEPRECATED. Use IdentityProvider.get_secure_cookie_kwargs # Default: {} # c.ServerApp.get_secure_cookie_kwargs = {} ## The identity provider class to use. # Default: &#39;jupyter_server.auth.identity.PasswordIdentityProvider&#39; # c.ServerApp.identity_provider_class = &#39;jupyter_server.auth.identity.PasswordIdentityProvider&#39; ## DEPRECATED. Use ZMQChannelsWebsocketConnection.iopub_data_rate_limit # Default: 0.0 # c.ServerApp.iopub_data_rate_limit = 0.0 ## DEPRECATED. Use ZMQChannelsWebsocketConnection.iopub_msg_rate_limit # Default: 0.0 # c.ServerApp.iopub_msg_rate_limit = 0.0 ## The IP address the Jupyter server will listen on. # Default: &#39;localhost&#39; # c.ServerApp.ip = &#39;localhost&#39; ## Supply extra arguments that will be passed to Jinja environment. # Default: {} # c.ServerApp.jinja_environment_options = {} ## Extra variables to supply to jinja templates when rendering. # Default: {} # c.ServerApp.jinja_template_vars = {} ## Dict of Python modules to load as Jupyter server extensions.Entry values can # be used to enable and disable the loading ofthe extensions. The extensions # will be loaded in alphabetical order. # Default: {} # c.ServerApp.jpserver_extensions = {} ## The kernel manager class to use. # Default: &#39;jupyter_server.services.kernels.kernelmanager.MappingKernelManager&#39; # c.ServerApp.kernel_manager_class = &#39;jupyter_server.services.kernels.kernelmanager.MappingKernelManager&#39; ## The kernel spec manager class to use. Should be a subclass of # `jupyter_client.kernelspec.KernelSpecManager`. # # The Api of KernelSpecManager is provisional and might change without warning # between this version of Jupyter and the next stable one. # Default: &#39;builtins.object&#39; # c.ServerApp.kernel_spec_manager_class = &#39;builtins.object&#39; ## The kernel websocket connection class to use. # Default: &#39;jupyter_server.services.kernels.connection.base.BaseKernelWebsocketConnection&#39; # c.ServerApp.kernel_websocket_connection_class = &#39;jupyter_server.services.kernels.connection.base.BaseKernelWebsocketConnection&#39; ## DEPRECATED. Use ZMQChannelsWebsocketConnection.kernel_ws_protocol # Default: &#39;&#39; # c.ServerApp.kernel_ws_protocol = &#39;&#39; ## The full path to a private key file for usage with SSL/TLS. # Default: &#39;&#39; # c.ServerApp.keyfile = &#39;&#39; ## DEPRECATED. Use ZMQChannelsWebsocketConnection.limit_rate # Default: False # c.ServerApp.limit_rate = False ## Hostnames to allow as local when allow_remote_access is False. # # Local IP addresses (such as 127.0.0.1 and ::1) are automatically accepted # as local as well. # Default: [&#39;localhost&#39;] # c.ServerApp.local_hostnames = [&#39;localhost&#39;] ## The date format used by logging formatters for %(asctime)s # See also: Application.log_datefmt # c.ServerApp.log_datefmt = &#39;%Y-%m-%d %H:%M:%S&#39; ## The Logging format template # See also: Application.log_format # c.ServerApp.log_format = &#39;[%(name)s]%(highlevel)s %(message)s&#39; ## Set the log level by value or name. # See also: Application.log_level # c.ServerApp.log_level = 30 ## # See also: Application.logging_config # c.ServerApp.logging_config = {} ## The login handler class to use. # Default: &#39;jupyter_server.auth.login.LegacyLoginHandler&#39; # c.ServerApp.login_handler_class = &#39;jupyter_server.auth.login.LegacyLoginHandler&#39; ## The logout handler class to use. # Default: &#39;jupyter_server.auth.logout.LogoutHandler&#39; # c.ServerApp.logout_handler_class = &#39;jupyter_server.auth.logout.LogoutHandler&#39; ## Sets the maximum allowed size of the client request body, specified in the # Content-Length request header field. If the size in a request exceeds the # configured value, a malformed HTTP message is returned to the client. # # Note: max_body_size is applied even in streaming mode. # Default: 536870912 # c.ServerApp.max_body_size = 536870912 ## Gets or sets the maximum amount of memory, in bytes, that is allocated for use # by the buffer manager. # Default: 536870912 # c.ServerApp.max_buffer_size = 536870912 ## Gets or sets a lower bound on the open file handles process resource limit. # This may need to be increased if you run into an OSError: [Errno 24] Too many # open files. This is not applicable when running on Windows. # Default: 0 # c.ServerApp.min_open_files_limit = 0 ## DEPRECATED, use root_dir. # Default: &#39;&#39; # c.ServerApp.notebook_dir = &#39;&#39; ## Whether to open in a browser after starting. # The specific browser used is platform dependent and # determined by the python standard library `webbrowser` # module, unless it is overridden using the --browser # (ServerApp.browser) configuration option. # Default: False # c.ServerApp.open_browser = False ## DEPRECATED in 2.0. Use PasswordIdentityProvider.hashed_password # Default: &#39;&#39; # c.ServerApp.password = &#39;&#39; ## DEPRECATED in 2.0. Use PasswordIdentityProvider.password_required # Default: False # c.ServerApp.password_required = False ## The port the server will listen on (env: JUPYTER_PORT). # Default: 0 # c.ServerApp.port = 0 ## The number of additional ports to try if the specified port is not available # (env: JUPYTER_PORT_RETRIES). # Default: 50 # c.ServerApp.port_retries = 50 ## Preferred starting directory to use for notebooks and kernels. # Default: &#39;&#39; # c.ServerApp.preferred_dir = &#39;&#39; ## DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib. # Default: &#39;disabled&#39; # c.ServerApp.pylab = &#39;disabled&#39; ## If True, display controls to shut down the Jupyter server, such as menu items # or buttons. # Default: True # c.ServerApp.quit_button = True ## DEPRECATED. Use ZMQChannelsWebsocketConnection.rate_limit_window # Default: 0.0 # c.ServerApp.rate_limit_window = 0.0 ## Reraise exceptions encountered loading server extensions? # Default: False # c.ServerApp.reraise_server_extension_failures = False ## The directory to use for notebooks and kernels. # Default: &#39;&#39; # c.ServerApp.root_dir = &#39;&#39; ## The session manager class to use. # Default: &#39;builtins.object&#39; # c.ServerApp.session_manager_class = &#39;builtins.object&#39; ## Instead of starting the Application, dump configuration to stdout # See also: Application.show_config # c.ServerApp.show_config = False ## Instead of starting the Application, dump configuration to stdout (as JSON) # See also: Application.show_config_json # c.ServerApp.show_config_json = False ## Shut down the server after N seconds with no kernelsrunning and no activity. # This can be used together with culling idle kernels # (MappingKernelManager.cull_idle_timeout) to shutdown the Jupyter server when # it&#39;s not in use. This is not precisely timed: it may shut down up to a minute # later. 0 (the default) disables this automatic shutdown. # Default: 0 # c.ServerApp.shutdown_no_activity_timeout = 0 ## The UNIX socket the Jupyter server will listen on. # Default: &#39;&#39; # c.ServerApp.sock = &#39;&#39; ## The permissions mode for UNIX socket creation (default: 0600). # Default: &#39;0600&#39; # c.ServerApp.sock_mode = &#39;0600&#39; ## Supply SSL options for the tornado HTTPServer. # See the tornado docs for details. # Default: {} # c.ServerApp.ssl_options = {} ## Paths to set up static files as immutable. # # This allow setting up the cache control of static files as immutable. It # should be used for static file named with a hash for instance. # Default: [] # c.ServerApp.static_immutable_cache = [] ## Supply overrides for terminado. Currently only supports "shell_command". # Default: {} # c.ServerApp.terminado_settings = {} ## Set to False to disable terminals. # # This does *not* make the server more secure by itself. # Anything the user can in a terminal, they can also do in a notebook. # # Terminals may also be automatically disabled if the terminado package # is not available. # Default: False # c.ServerApp.terminals_enabled = False ## DEPRECATED. Use IdentityProvider.token # Default: &#39;<DEPRECATED>&#39; # c.ServerApp.token = &#39;<DEPRECATED>&#39; ## Supply overrides for the tornado.web.Application that the Jupyter server uses. # Default: {} # c.ServerApp.tornado_settings = {} ## Whether to trust or not X-Scheme/X-Forwarded-Proto and X-Real-Ip/X-Forwarded- # For headerssent by the upstream reverse proxy. Necessary if the proxy handles # SSL # Default: False # c.ServerApp.trust_xheaders = False ## Disable launching browser by redirect file # For versions of notebook > 5.7.2, a security feature measure was added that # prevented the authentication token used to launch the browser from being visible. # This feature makes it difficult for other users on a multi-user system from # running code in your Jupyter session as you. # However, some environments (like Windows Subsystem for Linux (WSL) and Chromebooks), # launching a browser using a redirect file can lead the browser failing to load. # This is because of the difference in file structures/paths between the runtime and # the browser. # # Disabling this setting to False will disable this behavior, allowing the browser # to launch by using a URL and visible token (as before). # Default: True # c.ServerApp.use_redirect_file = True ## Specify where to open the server on startup. This is the # `new` argument passed to the standard library method `webbrowser.open`. # The behaviour is not guaranteed, but depends on browser support. Valid # values are: # # - 2 opens a new tab, # - 1 opens a new window, # - 0 opens in an existing window. # # See the `webbrowser.open` documentation for details. # Default: 2 # c.ServerApp.webbrowser_open_new = 2 ## Set the tornado compression options for websocket connections. # # This value will be returned from # :meth:`WebSocketHandler.get_compression_options`. None (default) will disable # compression. A dict (even an empty one) will enable compression. # # See the tornado docs for WebSocketHandler.get_compression_options for details. # Default: None # c.ServerApp.websocket_compression_options = None ## The base URL for websockets, # if it differs from the HTTP server (hint: it almost certainly doesn&#39;t). # # Should be in the form of an HTTP origin: ws[s]://hostname[:port] # Default: &#39;&#39; # c.ServerApp.websocket_url = &#39;&#39;
07-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值