[omd-commits] OMD Git: omd: omd: Added --apache-reload flag to omd create/ rm for executing a reload of the system apache instead of a restart

git version control git at mathias-kettner.de
Thu Feb 6 15:16:39 CET 2014


Module:   omd
Branch:   master
Commit:   837747129919c355e49fd7d5ebeae0e08c72aa6c
URL:      http://omdistro.org/projects/omd/repository/revisions/837747129919c355e49fd7d5ebeae0e08c72aa6c

Author:   Lars Michelsen <lm at mathias-kettner.de>
Date:     Thu Feb  6 15:16:26 2014 +0100
Commiter: Lars Michelsen <lm at mathias-kettner.de>
Date:     Thu Feb  6 15:16:26 2014 +0100

omd: Added --apache-reload flag to omd create/rm for executing a reload of the system apache instead of a restart

---

 Changelog          |    5 ++++-
 packages/omd/omd   |   30 +++++++++++++++++++++---------
 packages/omd/omd.8 |   14 ++++++++++++--
 3 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/Changelog b/Changelog
index 359523b..d26c5ee 100644
--- a/Changelog
+++ b/Changelog
@@ -10,7 +10,10 @@ This file documents the revision history for the Open Monitoring Distribution
           - perl-modules:
             - Added missing semikolon to fix syntax error
             - Added Monitoring-Plugin module
-          - omd: added nagios/icinga reload init hooks
+          - omd:
+            - Added --apache-reload flag to omd create/rm for executing a
+              reload of the system apache instead of a restart
+            - Added nagios/icinga reload init hooks
 
 1.10     Dec 15 2013
           - omd: More friendly error messages when init scripts do not exist
diff --git a/packages/omd/omd b/packages/omd/omd
index 73765f0..a587c2f 100644
--- a/packages/omd/omd
+++ b/packages/omd/omd
@@ -883,7 +883,7 @@ def delete_apache_hook(sitename):
 def reload_apache():
     sys.stdout.write("Reloading Apache...")
     sys.stdout.flush()
-    show_success(os.system("%s reload" % g_info["APACHE_CTL"]))
+    show_success(os.system("%s graceful" % g_info["APACHE_CTL"]))
 
 def restart_apache():
     if os.system("%s status >/dev/null 2>&1" % g_info["APACHE_INIT"]) >> 8 == 0:
@@ -2242,7 +2242,7 @@ def main_create(args, options={}):
         sys.stdout.write("Going to set AUTOSTART to off.\n")
 
     if not "no-init" in options:
-        init_site(config_settings)
+        init_site(config_settings, apache_reload = "apache-reload" in options)
         welcome_message()
 
     else:
@@ -2291,10 +2291,10 @@ def main_init(args, options):
 
 
     # Do the things that have been ommited on omd create --disabled
-    init_site()
+    init_site(apache_reload = "apache-reload" in options)
     welcome_message()
 
-def init_site(config_settings=None):
+def init_site(config_settings = None, apache_reload = False):
     # Create symbolic link to version
     create_version_symlink(g_sitename, OMD_VERSION)
 
@@ -2322,7 +2322,10 @@ def init_site(config_settings=None):
 
     # Create include-hook for Apache and reload apache
     create_apache_hook(g_sitename)
-    restart_apache()
+    if apache_reload:
+        reload_apache()
+    else:
+        restart_apache()
 
     # Mount and create contents of tmpfs. This must be done as normal
     # user. We also could do this at 'omd start', but this might confuse
@@ -2366,7 +2369,10 @@ def main_rm(args, options={}):
 
     # remove include-hook for Apache and tell apache
     delete_apache_hook(g_sitename)
-    restart_apache()
+    if "apache-reload" in options:
+        reload_apache()
+    else:
+        restart_apache()
 
 def create_site_dir(sitename):
     os.makedirs(site_dir(sitename))
@@ -2933,6 +2939,7 @@ commands = [
       ( "reuse", None, False, "do not create a site user, reuse existing one" ),
       ( "no-init",  "n",  False, "leave new site directory empty (a later omd init does this"),
       ( "no-autostart", "A", False, "set AUTOSTART to off (useful for test sites)"), 
+      ( "apache-reload",  False,  False, "Issue a reload of the system apache instead of a restart"),
     ],
     "Create a new site (-u UID, -g GID)",
 
@@ -2944,12 +2951,17 @@ commands = [
     "- Add tmpfs for the site to fstab and mount it"),
 
   ( "init",      True,  1, 1, False, "",       main_init,
-    [],
+    [
+      ( "apache-reload",  False,  False, "Issue a reload of the system apache instead of a restart"),
+    ],
     "Populate site directory with default files and enable the site", ""),
 
   ( "rm",        True,  1, 1, True, "",        main_rm,
-    [ ( "reuse", None, False, "assume --reuse on create, do not delete site user/group" ),
-      ( "kill", None, False, "kill processes of the site before deleting it" )],
+    [
+      ( "reuse", None, False, "assume --reuse on create, do not delete site user/group" ),
+      ( "kill", None, False, "kill processes of the site before deleting it" ),
+      ( "apache-reload",  False,  False, "Issue a reload of the system apache instead of a restart"),
+    ],
     "Remove a site (and its data)",
 
     "PLEASE NOTE: This action removes all configuration files\n"
diff --git a/packages/omd/omd.8 b/packages/omd/omd.8
index 919055b..dd3f81b 100644
--- a/packages/omd/omd.8
+++ b/packages/omd/omd.8
@@ -120,23 +120,33 @@ The following options can be used:
 \fB--no-init\fP Omits the population of the site's home directory and the integration into 
 the system Apache (/omd/apache/SITE.conf will be empty). 
 
+\fB--apache-reload\fP Issue a reaload of the apache process instead of the default restart
+
 .TP
-.B omd init SITE
+.B omd init [OPTIONS] SITE
 Initializes a site that has been created with \fBomd create --no-init\fP.
 This includes populating the site's home directory with the default
 configuration files and enabling the site (see \fBomd disable\fP). Afterwards
 the site is in the same state as after an \fBomd create\fP without \fB--no-init\fP.
 
+The following options can be used:
+
+\fB--apache-reload\fP Issue a reaload of the apache process instead of the default restart
+
 .TP
-.B omd [-f, --force] [--kill] rm         SITE             
+.B omd [-f, --force] rm [OPTIONS] SITE             
 Remove a site and all of its data. This includes deleting the
 directory \fB/omd/sites/\fPSITE and removing the system user
 and group of that site. This - of course - needs root permissions.
 
+The following options can be used:
+
 The option \fB--kill\fP will automatically kill all processes that
 use the temporary filesystem of the site before unmounting it.
 Otherwise the unmount and the removal of the site will fail.
 
+\fB--apache-reload\fP Issue a reaload of the apache process instead of the default restart
+
 .TP
 .B omd disable [--kill] SITE
 Disable a site. First the site will be stopped, if it is running.



More information about the omd-commits mailing list