From 1f53321b517ed223ae60b9d3881a78a2f780b747 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sun, 29 May 2016 20:22:45 +0530 Subject: [PATCH] Don't use init.d file, don't daemonize We pretty much only run in systemd environment and I don't see that changing any time soon. By relying on it, we can reduce some burden. Remove init script. Daemonizing is not needed for systemd. Remove code related daemonization. --- HACKING | 2 +- data/etc/init.d/plinth | 71 -------------------------- data/lib/systemd/system/plinth.service | 2 +- plinth/__main__.py | 10 ---- plinth/cfg.py | 1 - setup.py | 3 +- 6 files changed, 3 insertions(+), 86 deletions(-) delete mode 100755 data/etc/init.d/plinth diff --git a/HACKING b/HACKING index 8871ff947..8b15e5df7 100644 --- a/HACKING +++ b/HACKING @@ -18,7 +18,7 @@ 2. Plinth also support running without installing (as much as possible). Simply run it as: - $ sudo ./run --no-daemon --debug + $ sudo ./run --debug In this mode, Plinth runs in working directory without need for installation. It uses the plinth.conf config file in the working diff --git a/data/etc/init.d/plinth b/data/etc/init.d/plinth deleted file mode 100755 index adc7e80b7..000000000 --- a/data/etc/init.d/plinth +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh -# -# This file is part of Plinth. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# - -### BEGIN INIT INFO -# Provides: plinth -# Required-Start: $network $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: plinth web frontend -# Description: -# Control the plinth web frontend. -### END INIT INFO - -# This file is /etc/init.d/plinth - -DESC="embedded web frontend" -NAME=plinth - -DAEMON=/usr/bin/plinth -PID_FILE=/var/run/plinth.pid -SERVER_DIR=/plinth - -PLINTH_USER=plinth -PLINTH_GROUP=plinth - -test -x $DAEMON || exit 0 - -. /lib/lsb/init-functions - -case "$1" in - start) - log_daemon_msg "Starting $DESC" "$NAME" - start_daemon -p $PID_FILE $DAEMON --pidfile=$PID_FILE \ - --server_dir=$SERVER_DIR - log_end_msg $? - ;; - stop) - log_daemon_msg "Stopping $DESC" "$NAME" - killproc -p $PID_FILE $DAEMON - RETVAL=$? - [ $RETVAL -eq 0 ] && [ -e "$PID_FILE" ] && rm -f $PID_FILE - log_end_msg $RETVAL - ;; - restart|force-reload) - $0 stop - $0 start - ;; - status) - status_of_proc -p $PID_FILE "$DAEMON" plinth && exit 0 || exit $? - ;; - *) - echo "Usage: $NAME {start|stop|restart|force-reload|status}" >&2 - exit 1 - ;; -esac diff --git a/data/lib/systemd/system/plinth.service b/data/lib/systemd/system/plinth.service index 1685c7bc1..6d8958671 100644 --- a/data/lib/systemd/system/plinth.service +++ b/data/lib/systemd/system/plinth.service @@ -21,7 +21,7 @@ Documentation=man:plinth(1) After=network.target [Service] -ExecStart=/usr/bin/plinth --no-daemon +ExecStart=/usr/bin/plinth Restart=on-failure ExecReload=/bin/kill -HUP $MAINPID diff --git a/plinth/__main__.py b/plinth/__main__.py index d23fa1ed1..514a98e16 100644 --- a/plinth/__main__.py +++ b/plinth/__main__.py @@ -29,7 +29,6 @@ import stat import sys import cherrypy -from cherrypy.process.plugins import Daemonizer from plinth import cfg from plinth import module_loader @@ -56,9 +55,6 @@ def parse_arguments(): parser.add_argument( '--debug', action='store_true', default=cfg.debug, help='enable debugging and run server *insecurely*') - parser.add_argument( - '--no-daemon', action='store_true', default=cfg.no_daemon, - help='do not start as a daemon') parser.add_argument( '--setup', action='store_true', default=False, help='run setup tasks on all essential modules and exit') @@ -71,7 +67,6 @@ def parse_arguments(): cfg.pidfile = arguments.pidfile cfg.server_dir = arguments.server_dir cfg.debug = arguments.debug - cfg.no_daemon = arguments.no_daemon def setup_logging(): @@ -81,8 +76,6 @@ def setup_logging(): cherrypy.log.error_file = cfg.status_log_file cherrypy.log.access_file = cfg.access_log_file - if not cfg.no_daemon: - cherrypy.log.screen = False def setup_server(): @@ -152,9 +145,6 @@ def setup_server(): logger.debug('Serving static directory %s on %s', static_dir, urlprefix) - if not cfg.no_daemon: - Daemonizer(cherrypy.engine).subscribe() - cherrypy.engine.signal_handler.subscribe() diff --git a/plinth/cfg.py b/plinth/cfg.py index eab925093..9342235b4 100644 --- a/plinth/cfg.py +++ b/plinth/cfg.py @@ -39,7 +39,6 @@ port = None use_x_forwarded_host = False secure_proxy_ssl_header = None debug = False -no_daemon = False server_dir = '/' danube_edition = False diff --git a/setup.py b/setup.py index 466021859..efcd9432d 100755 --- a/setup.py +++ b/setup.py @@ -193,8 +193,7 @@ setuptools.setup( package_data={'plinth': ['templates/*', 'modules/*/templates/*', 'locale/*/LC_MESSAGES/*.[pm]o']}, - data_files=[('/etc/init.d', ['data/etc/init.d/plinth']), - ('/usr/lib/firewalld/services/', + data_files=[('/usr/lib/firewalld/services/', glob.glob('data/usr/lib/firewalld/services/*.xml')), ('/usr/lib/freedombox/setup.d/', ['data/usr/lib/freedombox/setup.d/86_plinth']),