diff --git a/HACKING.md b/HACKING.md
index d666e723b..ad393be82 100644
--- a/HACKING.md
+++ b/HACKING.md
@@ -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:
diff --git a/doc/plinth.xml b/doc/plinth.xml
index 3110e0ac5..33d53cc6c 100644
--- a/doc/plinth.xml
+++ b/doc/plinth.xml
@@ -38,7 +38,6 @@
plinthSERVER_DIR
-
@@ -101,25 +100,16 @@
-
-
-
-
- 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.
-
-
-
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.
@@ -222,12 +212,10 @@
Run Plinth in development mode
- $ plinth --debug --develop
+ $ plinth --develop
- 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.
diff --git a/plinth/__main__.py b/plinth/__main__.py
index c4f916413..541a004da 100644
--- a/plinth/__main__.py
+++ b/plinth/__main__.py
@@ -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()
diff --git a/plinth/cfg.py b/plinth/cfg.py
index 1354823e2..22753198c 100644
--- a/plinth/cfg.py
+++ b/plinth/cfg.py
@@ -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
diff --git a/plinth/module_loader.py b/plinth/module_loader.py
index af45ccef6..dd28eccdc 100644
--- a/plinth/module_loader.py
+++ b/plinth/module_loader.py
@@ -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