Comment 4 for bug 1691495

Revision history for this message
Rene Fragoso (ctrlrsf) wrote :

Actually what looks to be happening is that /etc/default/apache-htcacheclean is being included/sourced after DAEMON_ARGS has already been set. The init script sets some HTCACHECLEAN_* variables, then DAEMON_ARGS, and then eventually /etc/default/apache-htcacheclean is sourced. However, DAEMON_ARGS is never reset using the newly sourced ENV vars so they're never used (see bash -x debug output below).

As a workaround, instead of changing init script, you can also add DAEMON_ARGS to bottom of your /etc/default/apache-htcacheclean. Here's my DAEMON_ARGS, which I took directly from the init script:

DAEMON_ARGS="$HTCACHECLEAN_OPTIONS \
    -d$HTCACHECLEAN_DAEMON_INTERVAL \
    -P$PIDFILE -i \
    -p$HTCACHECLEAN_PATH \
    -l$HTCACHECLEAN_SIZE"

Snippet of bash -x /etc/init.d/apache-htcacheclean start:
...
+++ HTCACHECLEAN_SIZE=300M
+++ HTCACHECLEAN_DAEMON_INTERVAL=120
+++ HTCACHECLEAN_PATH=/var/cache/apache2/mod_cache_disk
+++ HTCACHECLEAN_OPTIONS=-n
+++ PIDDIR=/var/run/apache2/www-data
+++ PIDFILE=/var/run/apache2/www-data/apache-htcacheclean.pid
+++ DAEMON_ARGS='-n -d120 -P/var/run/apache2/www-data/apache-htcacheclean.pid -i -p/var/cache/apache2/mod_cache_disk -l300M'
++ NAME=apache-htcacheclean
++ DESC='Apache htcacheclean'
++ '[' none = /var/run/apache2/www-data/apache-htcacheclean.pid ']'
++ '[' -z /var/run/apache2/www-data/apache-htcacheclean.pid ']'
++ '[' none '!=' /usr/bin/htcacheclean ']'
++ '[' '!' -x /usr/bin/htcacheclean ']'
++ '[' -r /etc/default/apache-htcacheclean ']'
++ . /etc/default/apache-htcacheclean
+++ HTCACHECLEAN_MODE=daemon
+++ HTCACHECLEAN_SIZE=64M
+++ HTCACHECLEAN_DAEMON_INTERVAL=15
+++ HTCACHECLEAN_PATH=/dev/shm/htcache
+++ HTCACHECLEAN_OPTIONS=-n
++ . /lib/init/vars.sh
+++ TMPTIME=0
...
...
++ echo ' * Starting Apache htcacheclean' apache-htcacheclean
 * Starting Apache htcacheclean apache-htcacheclean
++ COL=
++ call do_start_cmd
++ cmd=do_start_cmd
++ shift
++ is_call_implemented do_start_cmd_override
++ command -V do_start_cmd_override
++ do_start_cmd_override
++ start-stop-daemon --start --quiet --pidfile /var/run/apache2/www-data/apache-htcacheclean.pid -u www-data --startas /usr/bin/htcacheclean --name htcacheclean --test

(DAEMON_ARGS is never changed and it has the arguments to start the daemon)

$ dpkg -l | grep apache2
ii apache2 2.4.18-2ubuntu3.4 amd64 Apache HTTP Server
ii apache2-bin 2.4.18-2ubuntu3.4 amd64 Apache HTTP Server (modules and other binary files)
ii apache2-data 2.4.18-2ubuntu3.4 all Apache HTTP Server (common files)
ii apache2-utils 2.4.18-2ubuntu3.4 amd64 Apache HTTP Server (utility programs for web servers)