mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
Merge ./run --debug into --develop option
Signed-off-by: Michael Pimmer <info@fonfon.at> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
b0e09736d0
commit
00ac068133
@ -68,13 +68,16 @@ However, for some reason, you wish setup manually, the following tips will help:
|
||||
as possible). Simply run it as:
|
||||
|
||||
```
|
||||
$ sudo ./run --debug --develop
|
||||
$ sudo ./run --develop
|
||||
```
|
||||
|
||||
In this mode, FreedomBox Service (Plinth) runs in working directory without
|
||||
need for installation. The `plinth.conf` config file and the action
|
||||
In this mode, FreedomBox Service (Plinth) runs from the working directory
|
||||
without need for installation. The server restarts automatically when any
|
||||
python file changes. The `plinth.conf` config file and the action
|
||||
scripts of the working directory are used. It creates all that data and
|
||||
runtime files in `data/var/*`.
|
||||
More extensive debugging is enabled, Django security features are disabled
|
||||
and module initialization errors will not pass silently.
|
||||
|
||||
*Note:* This mode is supported only in a limited manner. The following are
|
||||
the unknown issues with it:
|
||||
|
||||
@ -38,7 +38,6 @@
|
||||
<command>plinth</command>
|
||||
<arg><option>-h, </option><option>--help</option></arg>
|
||||
<arg><option>--server_dir</option><arg choice="req">SERVER_DIR</arg></arg>
|
||||
<arg><option>--debug</option></arg>
|
||||
<arg><option>--develop</option></arg>
|
||||
<arg><option>--diagnose</option></arg>
|
||||
<arg>
|
||||
@ -101,25 +100,16 @@
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>--debug</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Enable debug mode. Turn off Django security features.
|
||||
Print extra debug messages. Monitor source files for
|
||||
changes and restart Plinth on modifications. Turn on
|
||||
Django debug mode to show details on error pages. Die if
|
||||
there is an error during module initialization.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>--develop</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Enable development mode. Use plinth.config and the actions_dir
|
||||
of the current working directory, opposed to the actions_dir
|
||||
and plinth.config file of the operating system installation.
|
||||
of the current working directory. Enables extra debug messages,
|
||||
enable Django debug mode for detailed error pages and and turn off
|
||||
Django security features. Monitor source files for changes and
|
||||
restart Plinth on modifications. Die if there is an error during
|
||||
module initialization.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@ -222,12 +212,10 @@
|
||||
|
||||
<example>
|
||||
<title>Run Plinth in development mode</title>
|
||||
<synopsis>$ plinth --debug --develop</synopsis>
|
||||
<synopsis>$ plinth --develop</synopsis>
|
||||
<para>
|
||||
Enable debug and development mode and run on terminal. This uses
|
||||
the configuration and action files of the current working directory and
|
||||
gives debugging information like extended error pages, or not failing
|
||||
silently on module initialization errors.
|
||||
Run in development mode on the terminal. Enable auto-reloading and
|
||||
more extensive debugging.
|
||||
</para>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
@ -34,7 +34,7 @@ import cherrypy
|
||||
from plinth import cfg, menu, module_loader, service, setup
|
||||
|
||||
axes.default_app_config = "plinth.axes_app_config.AppConfig"
|
||||
precedence_commandline_arguments = ["server_dir", "debug", "develop"]
|
||||
precedence_commandline_arguments = ["server_dir", "develop"]
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -47,11 +47,9 @@ def parse_arguments():
|
||||
# TODO: server_dir is actually a url prefix; use a better variable name
|
||||
parser.add_argument('--server_dir', default=None,
|
||||
help='web server path under which to serve')
|
||||
parser.add_argument('--debug', action='store_true', default=None,
|
||||
help='enable debugging and run server *insecurely*')
|
||||
parser.add_argument('--develop', action='store_true', default=None,
|
||||
help=('use files from current source code folder '
|
||||
'instead of system-installed plinth files'))
|
||||
help=('run Plinth *insecurely* from current folder; '
|
||||
'enable auto-reloading and debugging options'))
|
||||
parser.add_argument(
|
||||
'--setup', default=False, nargs='*',
|
||||
help='run setup tasks on all essential modules and exit')
|
||||
@ -79,8 +77,8 @@ def setup_logging():
|
||||
# Capture all Python warnings such as deprecation warnings
|
||||
logging.captureWarnings(True)
|
||||
|
||||
# Log all deprecation warnings when in debug mode
|
||||
if cfg.debug:
|
||||
# Log all deprecation warnings when in develop mode
|
||||
if cfg.develop:
|
||||
warnings.filterwarnings('default', '', DeprecationWarning)
|
||||
warnings.filterwarnings('default', '', PendingDeprecationWarning)
|
||||
warnings.filterwarnings('default', '', ImportWarning)
|
||||
@ -96,7 +94,7 @@ def setup_server():
|
||||
'server.socket_port': cfg.port,
|
||||
'server.thread_pool': 10,
|
||||
# Avoid stating files once per second in production
|
||||
'engine.autoreload.on': cfg.debug,
|
||||
'engine.autoreload.on': cfg.develop,
|
||||
})
|
||||
|
||||
application = django.core.wsgi.get_wsgi_application()
|
||||
@ -189,7 +187,7 @@ def configure_django():
|
||||
},
|
||||
'root': {
|
||||
'handlers': ['console', 'file'],
|
||||
'level': 'DEBUG' if cfg.debug else 'INFO'
|
||||
'level': 'DEBUG' if cfg.develop else 'INFO'
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,7 +267,7 @@ def configure_django():
|
||||
'NAME': cfg.store_file
|
||||
}
|
||||
},
|
||||
DEBUG=cfg.debug,
|
||||
DEBUG=cfg.develop,
|
||||
FORCE_SCRIPT_NAME=cfg.server_dir,
|
||||
INSTALLED_APPS=applications,
|
||||
IPWARE_META_PRECEDENCE_ORDER=('HTTP_X_FORWARDED_FOR',),
|
||||
@ -312,7 +310,7 @@ def configure_django():
|
||||
logger.debug('Configured Django with applications - %s', applications)
|
||||
|
||||
logger.debug('Creating or adding new tables to data file')
|
||||
verbosity = 1 if cfg.debug else 0
|
||||
verbosity = 1 if cfg.develop else 0
|
||||
django.core.management.call_command('migrate', '--fake-initial',
|
||||
interactive=False, verbosity=verbosity)
|
||||
os.chmod(cfg.store_file, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
|
||||
@ -387,14 +385,14 @@ def adapt_config(arguments):
|
||||
def main():
|
||||
"""Intialize and start the application"""
|
||||
arguments = parse_arguments()
|
||||
config_paths = {}
|
||||
|
||||
if arguments.develop:
|
||||
# use the root and plinth.config of the current working directory
|
||||
file_path, root_directory = cfg.get_fallback_config_paths()
|
||||
config_paths['file_path'] = file_path
|
||||
config_paths['root_directory'] = root_directory
|
||||
config_path, root_directory = cfg.get_fallback_config_paths()
|
||||
cfg.read(config_path, root_directory)
|
||||
else:
|
||||
cfg.read()
|
||||
|
||||
cfg.read(**config_paths)
|
||||
adapt_config(arguments)
|
||||
|
||||
setup_logging()
|
||||
|
||||
@ -35,7 +35,7 @@ host = None
|
||||
port = None
|
||||
use_x_forwarded_host = False
|
||||
secure_proxy_ssl_header = None
|
||||
debug = False
|
||||
develop = False
|
||||
server_dir = '/'
|
||||
danube_edition = False
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ def load_modules():
|
||||
except Exception as exception:
|
||||
logger.exception('Could not import %s: %s', module_import_path,
|
||||
exception)
|
||||
if cfg.debug:
|
||||
if cfg.develop:
|
||||
raise
|
||||
|
||||
ordered_modules = []
|
||||
@ -120,7 +120,7 @@ def _include_module_urls(module_import_path, module_name):
|
||||
r'', django.conf.urls.include((url_module, module_name)))]
|
||||
except ImportError:
|
||||
logger.debug('No URLs for %s', module_name)
|
||||
if cfg.debug:
|
||||
if cfg.develop:
|
||||
raise
|
||||
|
||||
|
||||
@ -140,7 +140,7 @@ def _initialize_module(module_name, module):
|
||||
except Exception as exception:
|
||||
logger.exception('Exception while running init for %s: %s',
|
||||
module, exception)
|
||||
if cfg.debug:
|
||||
if cfg.develop:
|
||||
raise
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user