diff --git a/docs/features/safemode.rst b/docs/features/safemode.rst index a99cbf97..c90d30d6 100644 --- a/docs/features/safemode.rst +++ b/docs/features/safemode.rst @@ -16,6 +16,9 @@ Additionally, OctoPrint allows uninstalling plugins in this mode, allowing recov a third party plugin causes the server to not start up or the web interface to not render or function correctly anymore. +Whenever reporting an issue with OctoPrint, please always attempt to reproduce it in safe mode as well to +ensure it really is an issue in OctoPrint itself and now caused by one of your installed third party plugins. + .. _sec-features-safemode-how: How to start OctoPrint in safe mode @@ -23,15 +26,37 @@ How to start OctoPrint in safe mode There exist three ways to start OctoPrint in safe mode: - * since OctoPrint 1.3.2: by selecting "Restart OctoPrint in safe mode" from the "System" menu, - if the "Restart OctoPrint" server command has been correctly configured (see :numref:`fig-features-safemode-systemmenu`). - * by starting OctoPrint with the command line parameter ``--safe``, e.g. ``octoprint serve --safe`` - * by setting the option ``server.startOnceInSafeMode`` in :ref:`config.yaml ` - to ``true`` and restarting + * by selecting "Restart OctoPrint in safe mode" from the "System" menu, + if the "Restart OctoPrint" server command has been correctly configured (since OctoPrint 1.3.2, + see :numref:`fig-features-safemode-systemmenu`) + * by setting the flag ``server.startOnceInSafeMode`` in :ref:`config.yaml ` + to ``true`` and restarting. To set this flag you have the following options: + + * from command line run ``octoprint safemode`` (since OctoPrint 1.3.6) + * from command line run ``octoprint config set --bool server.startOnceInSafeMode true`` (fixed in OctoPrint 1.3.6) + * use the `Yamlpatcher Plugin `_ and enter & apply the patch + ``[["set", "server.startOnceInSafeMode", true]]`` + * edit ``config.yaml`` manually with a text editor, locate the ``server`` block if it already exists or create it + if it doesn't and add ``startOnceInSafeMode: true`` to it: + + .. code-block:: yaml + + # ... + server: + startOnceInSafeMode: true + # ... + + Please also refer to the :ref:`YAML primer `. + * by starting OctoPrint with the command line parameter ``--safe``, e.g. ``octoprint serve --safe`` (don't forget to + shutdown OctoPrint first before doing this) The last two options will have OctoPrint enable safe mode only for the next server start - once you restart OctoPrint again, safe mode will be disabled again. +.. note:: + + **OctoPi users**: For you that's ``~/oprint/bin/octoprint`` wherever it says just ``octoprint``. + .. _fig-features-safemode-systemmenu: .. figure:: ../images/features-safemode-systemmenu.png :align: center diff --git a/src/octoprint/cli/__init__.py b/src/octoprint/cli/__init__.py index 1cc3d82e..9562b173 100644 --- a/src/octoprint/cli/__init__.py +++ b/src/octoprint/cli/__init__.py @@ -102,7 +102,7 @@ def standard_options(hidden=False): options = [ factory("--basedir", "-b", type=click.Path(), callback=set_ctx_obj_option, is_eager=True, expose_value=False, - help="Specify the basedir to use for uploads, timelapses etc."), + help="Specify the basedir to use for configs, uploads, timelapses etc."), factory("--config", "-c", "configfile", type=click.Path(), callback=set_ctx_obj_option, is_eager=True, expose_value=False, help="Specify the config file to use."), factory("--verbose", "-v", "verbosity", count=True, callback=set_ctx_obj_option, is_eager=True, expose_value=False, diff --git a/src/octoprint/cli/config.py b/src/octoprint/cli/config.py index 319069a2..3554a14d 100644 --- a/src/octoprint/cli/config.py +++ b/src/octoprint/cli/config.py @@ -54,7 +54,7 @@ def config(ctx): ctx.obj.settings = init_settings(get_ctx_obj_option(ctx, "basedir", None), get_ctx_obj_option(ctx, "configfile", None)) except FatalStartupError as e: click.echo(e.message, err=True) - click.echo("There was a fatal error initializing the client.", err=True) + click.echo("There was a fatal error initializing the settings manager.", err=True) ctx.exit(-1) diff --git a/src/octoprint/cli/server.py b/src/octoprint/cli/server.py index cfadc559..5789af64 100644 --- a/src/octoprint/cli/server.py +++ b/src/octoprint/cli/server.py @@ -125,6 +125,27 @@ def server_commands(): pass +@server_commands.command(name="safemode") +@standard_options(hidden=True) +@click.pass_context +def enable_safemode(ctx, **kwargs): + """Sets the safe mode flag for the next start.""" + from octoprint import init_settings, FatalStartupError + + logging.basicConfig(level=logging.DEBUG if get_ctx_obj_option(ctx, "verbosity", 0) > 0 else logging.WARN) + try: + settings = init_settings(get_ctx_obj_option(ctx, "basedir", None), get_ctx_obj_option(ctx, "configfile", None)) + except FatalStartupError as e: + click.echo(e.message, err=True) + click.echo("There was a fatal error initializing the settings manager.", err=True) + ctx.exit(-1) + + settings.setBoolean(["server", "startOnceInSafeMode"], True) + settings.save() + + click.echo("Safe mode flag set, OctoPrint will start in safe mode on next restart.") + + @server_commands.command(name="serve") @server_options @standard_options(hidden=True)