summaryrefslogtreecommitdiff
path: root/bin/swift-container-auditor
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2010-07-14 09:58:38 -0500
committerMonty Taylor <mordred@inaugust.com>2010-07-14 09:58:38 -0500
commit76e6c6ea6c2272b7a5401adeb5c1be1f3badf5b9 (patch)
tree4b7cd88ba0508e8c4f717a9fd0301aa0965d4867 /bin/swift-container-auditor
parent81e79a87c41498cfbbbef2299339fc967a3fba1f (diff)
downloadswift-76e6c6ea6c2272b7a5401adeb5c1be1f3badf5b9.tar.gz
Renamed bin files in the tree so that setup.py install does the same thing
as a deb install.
Diffstat (limited to 'bin/swift-container-auditor')
-rwxr-xr-xbin/swift-container-auditor69
1 files changed, 69 insertions, 0 deletions
diff --git a/bin/swift-container-auditor b/bin/swift-container-auditor
new file mode 100755
index 000000000..1ff1682c5
--- /dev/null
+++ b/bin/swift-container-auditor
@@ -0,0 +1,69 @@
+#!/usr/bin/python
+# Copyright (c) 2010 OpenStack, LLC.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os
+import signal
+import sys
+from ConfigParser import ConfigParser
+
+from swift.container.auditor import ContainerAuditor
+from swift.common import utils
+
+if __name__ == '__main__':
+ if len(sys.argv) < 2:
+ print "Usage: container-auditor CONFIG_FILE [once]"
+ sys.exit()
+
+ once = len(sys.argv) > 2 and sys.argv[2] == 'once'
+
+ c = ConfigParser()
+ if not c.read(sys.argv[1]):
+ print "Unable to read config file."
+ sys.exit(1)
+
+ server_conf = dict(c.items('container-server'))
+ if c.has_section('container-auditor'):
+ auditor_conf = dict(c.items('container-auditor'))
+ else:
+ print "Unable to find container-auditor config section in %s." % \
+ sys.argv[1]
+ sys.exit(1)
+
+ logger = utils.get_logger(auditor_conf, 'container-auditor')
+ # log uncaught exceptions
+ sys.excepthook = lambda *exc_info: \
+ logger.critical('UNCAUGHT EXCEPTION', exc_info=exc_info)
+ sys.stdout = sys.stderr = utils.LoggerFileObject(logger)
+
+ utils.drop_privileges(server_conf.get('user', 'swift'))
+
+ try:
+ os.setsid()
+ except OSError:
+ pass
+
+ def kill_children(*args):
+ signal.signal(signal.SIGTERM, signal.SIG_IGN)
+ os.killpg(0, signal.SIGTERM)
+ sys.exit()
+
+ signal.signal(signal.SIGTERM, kill_children)
+
+ auditor = ContainerAuditor(server_conf, auditor_conf)
+ if once:
+ auditor.audit_once()
+ else:
+ auditor.audit_forever()