Browse code

Clean up horizon apache logs on unstack

It feels like the right think to do. Moreover it will avoid to display
horizon errors from a previous devstack run that would be displayed because
of the tail -f in start_horizon()

Change-Id: Id1ab272e60e0733a4feef3b85029f438f2273cb0

JordanP authored on 2013/05/09 05:19:59
Showing 1 changed files
... ...
@@ -38,6 +38,18 @@ HORIZON_SETTINGS=${HORIZON_SETTINGS:-$HORIZON_DIR/openstack_dashboard/local/loca
38 38
 APACHE_USER=${APACHE_USER:-$USER}
39 39
 APACHE_GROUP=${APACHE_GROUP:-$(id -gn $APACHE_USER)}
40 40
 
41
+# Set up service name and configuration path
42
+if is_ubuntu; then
43
+    APACHE_NAME=apache2
44
+    APACHE_CONF=sites-available/horizon
45
+elif is_fedora; then
46
+    APACHE_NAME=httpd
47
+    APACHE_CONF=conf.d/horizon.conf
48
+elif is_suse; then
49
+    APACHE_NAME=apache2
50
+    APACHE_CONF=vhosts.d/horizon.conf
51
+fi
52
+
41 53
 
42 54
 # Functions
43 55
 # ---------
... ...
@@ -135,8 +147,6 @@ function init_horizon() {
135 135
 
136 136
     HORIZON_REQUIRE=''
137 137
     if is_ubuntu; then
138
-        APACHE_NAME=apache2
139
-        APACHE_CONF=sites-available/horizon
140 138
         # Clean up the old config name
141 139
         sudo rm -f /etc/apache2/sites-enabled/000-default
142 140
         # Be a good citizen and use the distro tools here
... ...
@@ -145,9 +155,6 @@ function init_horizon() {
145 145
         # WSGI isn't enabled by default, enable it
146 146
         sudo a2enmod wsgi
147 147
     elif is_fedora; then
148
-        APACHE_NAME=httpd
149
-        APACHE_CONF=conf.d/horizon.conf
150
-
151 148
         if [[ "$os_RELEASE" -ge "18" ]]; then
152 149
             # fedora 18 has Require all denied  in its httpd.conf
153 150
             # and requires explicit Require all granted
... ...
@@ -155,14 +162,16 @@ function init_horizon() {
155 155
         fi
156 156
         sudo sed '/^Listen/s/^.*$/Listen 0.0.0.0:80/' -i /etc/httpd/conf/httpd.conf
157 157
     elif is_suse; then
158
-        APACHE_NAME=apache2
159
-        APACHE_CONF=vhosts.d/horizon.conf
160 158
         # WSGI isn't enabled by default, enable it
161 159
         sudo a2enmod wsgi
162 160
     else
163 161
         exit_distro_not_supported "apache configuration"
164 162
     fi
165 163
 
164
+    # Remove old log files that could mess with how devstack detects whether Horizon
165
+    # has been successfully started (see start_horizon() and functions::screen_it())
166
+    sudo rm -f /var/log/$APACHE_NAME/horizon_*
167
+
166 168
     # Configure apache to run horizon
167 169
     sudo sh -c "sed -e \"
168 170
         s,%USER%,$APACHE_USER,g;
... ...
@@ -219,12 +228,8 @@ function start_horizon() {
219 219
 
220 220
 # stop_horizon() - Stop running processes (non-screen)
221 221
 function stop_horizon() {
222
-    if is_ubuntu; then
223
-        stop_service apache2
224
-    elif is_fedora; then
225
-        stop_service httpd
226
-    elif is_suse; then
227
-        stop_service apache2
222
+    if [ -n "$APACHE_NAME" ]; then
223
+        stop_service $APACHE_NAME
228 224
     else
229 225
         exit_distro_not_supported "apache configuration"
230 226
     fi