New sub command "octoprint safemode"
Sets server.startOnceInSafeMode flag to true. Probably easier for a lot of people than editing a config file or running OctoPrint manually from command line, in case the built-in "Restart in safe mode" system command is not an option.
This commit is contained in:
parent
46bd2ce7e9
commit
38c410f80f
4 changed files with 53 additions and 7 deletions
|
|
@ -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 <sec-configuration-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 <sec-configuration-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 <http://plugins.octoprint.org/plugins/yamlpatcher/>`_ 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 <sec-configuration-yaml>`.
|
||||
* 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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue