summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorChuck Thier <cthier@gmail.com>2010-08-24 13:41:58 +0000
committerChuck Thier <cthier@gmail.com>2010-08-24 13:41:58 +0000
commitc62707ae72ebeb7da99e7622f889a66ae5d7fc79 (patch)
tree342cdae753ff614471784f4273ca6fb4c3ad7e7d /bin
parent85e043e9a2823eea48b95c0bbe5cc811af9fb79e (diff)
downloadswift-c62707ae72ebeb7da99e7622f889a66ae5d7fc79.tar.gz
Refactored logging configuration so that it has sane defaults
Diffstat (limited to 'bin')
-rwxr-xr-xbin/swift-account-auditor15
-rwxr-xr-xbin/swift-account-reaper13
-rwxr-xr-xbin/swift-account-replicator15
-rwxr-xr-xbin/swift-account-server4
-rwxr-xr-xbin/swift-auth-server4
-rwxr-xr-xbin/swift-container-auditor15
-rwxr-xr-xbin/swift-container-replicator17
-rwxr-xr-xbin/swift-container-server5
-rwxr-xr-xbin/swift-container-updater16
-rwxr-xr-xbin/swift-object-auditor17
-rwxr-xr-xbin/swift-object-replicator18
-rwxr-xr-xbin/swift-object-server4
-rwxr-xr-xbin/swift-object-updater18
-rwxr-xr-xbin/swift-proxy-server4
14 files changed, 31 insertions, 134 deletions
diff --git a/bin/swift-account-auditor b/bin/swift-account-auditor
index cba89e9e6..681adc6a2 100755
--- a/bin/swift-account-auditor
+++ b/bin/swift-account-auditor
@@ -24,23 +24,12 @@ from swift.common import utils
if __name__ == '__main__':
if len(sys.argv) < 2:
- print "Usage: account-auditor CONFIG_FILE [once]"
+ print "Usage: swift-account-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)
-
- if c.has_section('account-auditor'):
- conf = dict(c.items('account-auditor'))
- else:
- print "Unable to find account-auditor config section in %s." % \
- sys.argv[1]
- sys.exit(1)
-
+ conf = utils.readconf(sys.argv[1], 'account-auditor')
logger = utils.get_logger(conf)
# log uncaught exceptions
sys.excepthook = lambda *exc_info: \
diff --git a/bin/swift-account-reaper b/bin/swift-account-reaper
index c5619d078..444d19a09 100755
--- a/bin/swift-account-reaper
+++ b/bin/swift-account-reaper
@@ -29,18 +29,7 @@ if __name__ == '__main__':
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)
-
- if c.has_section('account-reaper'):
- conf = dict(c.items('account-reaper'))
- else:
- print "Unable to find account-reaper config section in %s." % \
- sys.argv[1]
- sys.exit(1)
-
+ conf = utils.readconf(sys.argv[1], 'account-reaper')
logger = utils.get_logger(conf)
# log uncaught exceptions
sys.excepthook = lambda *exc_info: \
diff --git a/bin/swift-account-replicator b/bin/swift-account-replicator
index 284c75159..18bea931a 100755
--- a/bin/swift-account-replicator
+++ b/bin/swift-account-replicator
@@ -32,22 +32,11 @@ if __name__ == '__main__':
optlist, args = getopt.getopt(sys.argv[1:], '', ['once'])
if not args:
- print "Usage: account-replicator <--once> CONFIG_FILE [once]"
+ print "Usage: swift-account-replicator <--once> CONFIG_FILE [once]"
sys.exit()
- c = ConfigParser()
- if not c.read(args[0]):
- print "Unable to read config file."
- sys.exit(1)
once = len(args) > 1 and args[1] == 'once'
-
- if c.has_section('account-replicator'):
- conf = dict(c.items('account-replicator'))
- else:
- print "Unable to find account-replicator config section in %s." % \
- args[0]
- sys.exit(1)
-
+ conf = utils.readconf(sys.argv[1], 'account-replicator')
utils.drop_privileges(conf.get('user', 'swift'))
if once or '--once' in [opt[0] for opt in optlist]:
AccountReplicator(conf).replicate_once()
diff --git a/bin/swift-account-server b/bin/swift-account-server
index 6be5706ea..8b9a1ec68 100755
--- a/bin/swift-account-server
+++ b/bin/swift-account-server
@@ -20,6 +20,6 @@ from swift.common.wsgi import run_wsgi
if __name__ == '__main__':
if len(sys.argv) != 2:
- print "Usage: %s CONFIG_FILE"
- run_wsgi(sys.argv[1], default_port=6002)
+ print "Usage: %s CONFIG_FILE" % sys.argv[0]
+ run_wsgi(sys.argv[1], 'account-server', default_port=6002)
diff --git a/bin/swift-auth-server b/bin/swift-auth-server
index 5f32912a9..62e1d8b59 100755
--- a/bin/swift-auth-server
+++ b/bin/swift-auth-server
@@ -20,6 +20,6 @@ from swift.common.wsgi import run_wsgi
if __name__ == '__main__':
if len(sys.argv) != 2:
- print "Usage: %s CONFIG_FILE"
- run_wsgi(sys.argv[1], default_port=11000)
+ print "Usage: %s CONFIG_FILE" % sys.argv[0]
+ run_wsgi(sys.argv[1], 'auth-server', default_port=11000)
diff --git a/bin/swift-container-auditor b/bin/swift-container-auditor
index b00135003..3f22fbf69 100755
--- a/bin/swift-container-auditor
+++ b/bin/swift-container-auditor
@@ -24,23 +24,12 @@ from swift.common import utils
if __name__ == '__main__':
if len(sys.argv) < 2:
- print "Usage: container-auditor CONFIG_FILE [once]"
+ print "Usage: swift-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)
-
- if c.has_section('container-auditor'):
- conf = dict(c.items('container-auditor'))
- else:
- print "Unable to find container-auditor config section in %s." % \
- sys.argv[1]
- sys.exit(1)
-
+ conf = utils.readconf(sys.argv[1], 'container-auditor')
logger = utils.get_logger(conf)
# log uncaught exceptions
sys.excepthook = lambda *exc_info: \
diff --git a/bin/swift-container-replicator b/bin/swift-container-replicator
index 663cb51db..6e8ae0f41 100755
--- a/bin/swift-container-replicator
+++ b/bin/swift-container-replicator
@@ -32,22 +32,11 @@ if __name__ == '__main__':
optlist, args = getopt.getopt(sys.argv[1:], '', ['once'])
if not args:
- print "Usage: container-replicator <--once> CONFIG_FILE [once]"
- sys.exit()
-
- c = ConfigParser()
- if not c.read(args[0]):
- print "Unable to read config file."
- sys.exit(1)
- once = len(args) > 1 and args[1] == 'once'
-
- if c.has_section('container-replicator'):
- conf = dict(c.items('container-replicator'))
- else:
- print "Unable to find container-replicator config section in %s." % \
- args[0]
+ print "Usage: swift-container-replicator <--once> CONFIG_FILE [once]"
sys.exit(1)
+ once = len(args) > 1 and args[1] == 'once'
+ conf = utils.readconf(args[0], 'container-replicator')
utils.drop_privileges(conf.get('user', 'swift'))
if once or '--once' in [opt[0] for opt in optlist]:
ContainerReplicator(conf).replicate_once()
diff --git a/bin/swift-container-server b/bin/swift-container-server
index f707eb091..02201041b 100755
--- a/bin/swift-container-server
+++ b/bin/swift-container-server
@@ -20,6 +20,5 @@ from swift.common.wsgi import run_wsgi
if __name__ == '__main__':
if len(sys.argv) != 2:
- print "Usage: %s CONFIG_FILE"
- run_wsgi(sys.argv[1], default_port=6001)
-
+ print "Usage: %s CONFIG_FILE" % sys.argv[0]
+ run_wsgi(sys.argv[1], 'container-server', default_port=6001)
diff --git a/bin/swift-container-updater b/bin/swift-container-updater
index 7c2311512..c582d1557 100755
--- a/bin/swift-container-updater
+++ b/bin/swift-container-updater
@@ -24,23 +24,11 @@ from swift.common import utils
if __name__ == '__main__':
if len(sys.argv) < 2:
- print "Usage: container-updater CONFIG_FILE [once]"
+ print "Usage: swift-container-updater 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)
-
- if c.has_section('container-updater'):
- conf = dict(c.items('container-updater'))
- else:
- print "Unable to find container-updater config section in %s." % \
- sys.argv[1]
- sys.exit(1)
-
+ conf = readconf(sys.argv[1], 'container-updater')
utils.drop_privileges(conf.get('user', 'swift'))
try:
diff --git a/bin/swift-object-auditor b/bin/swift-object-auditor
index e995ad872..a80065414 100755
--- a/bin/swift-object-auditor
+++ b/bin/swift-object-auditor
@@ -17,30 +17,17 @@
import os
import signal
import sys
-from ConfigParser import ConfigParser
from swift.obj.auditor import ObjectAuditor
from swift.common import utils
if __name__ == '__main__':
if len(sys.argv) < 2:
- print "Usage: object-auditor CONFIG_FILE [once]"
+ print "Usage: swift-object-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)
-
- if c.has_section('object-auditor'):
- conf = dict(c.items('object-auditor'))
- else:
- print "Unable to find object-auditor config section in %s." % \
- sys.argv[1]
- sys.exit(1)
-
+ conf = utils.readconf(sys.argv[1], 'object-auditor')
logger = utils.get_logger(conf)
# log uncaught exceptions
sys.excepthook = lambda *exc_info: \
diff --git a/bin/swift-object-replicator b/bin/swift-object-replicator
index 2f9c4a63e..c01c96aff 100755
--- a/bin/swift-object-replicator
+++ b/bin/swift-object-replicator
@@ -15,7 +15,6 @@
# limitations under the License.
import sys
-from ConfigParser import ConfigParser
import logging
import time
@@ -23,25 +22,16 @@ from eventlet import sleep, hubs
hubs.use_hub('poll')
from swift.obj.replicator import ObjectReplicator
-from swift.common.utils import get_logger, drop_privileges, LoggerFileObject
+from swift.common.utils import get_logger, drop_privileges, LoggerFileObject, \
+ readconf
TRUE_VALUES = set(('true', '1', 'yes', 'True', 'Yes'))
if __name__ == '__main__':
if len(sys.argv) < 2:
- print "Usage: object-replicator CONFIG_FILE [once]"
+ print "Usage: swift-object-replicator CONFIG_FILE [once]"
sys.exit()
- c = ConfigParser()
- if not c.read(sys.argv[1]):
- print "Unable to read config file"
- sys.exit(1)
- if c.has_section('object-replicator'):
- conf = dict(c.items('object-replicator'))
- else:
- print "Unable to find object-replicator config section in %s" % \
- sys.argv[1]
- sys.exit(1)
-
+ conf = readconf(sys.argv[1], "object-replicator")
once = len(sys.argv) > 2 and sys.argv[2] == 'once'
logger = get_logger(conf)
# log uncaught exceptions
diff --git a/bin/swift-object-server b/bin/swift-object-server
index ce74b1719..58b5120bd 100755
--- a/bin/swift-object-server
+++ b/bin/swift-object-server
@@ -20,5 +20,5 @@ from swift.common.wsgi import run_wsgi
if __name__ == '__main__':
if len(sys.argv) != 2:
- print "Usage: %s CONFIG_FILE"
- run_wsgi(sys.argv[1], default_port=6000)
+ print "Usage: %s CONFIG_FILE" % sys.argv[0]
+ run_wsgi(sys.argv[1], 'object-server', default_port=6000)
diff --git a/bin/swift-object-updater b/bin/swift-object-updater
index a9512a4e7..375e63ec8 100755
--- a/bin/swift-object-updater
+++ b/bin/swift-object-updater
@@ -17,30 +17,18 @@
import os
import signal
import sys
-from ConfigParser import ConfigParser
from swift.obj.updater import ObjectUpdater
from swift.common import utils
if __name__ == '__main__':
if len(sys.argv) < 2:
- print "Usage: object-updater 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."
+ print "Usage: swift-object-updater CONFIG_FILE [once]"
sys.exit(1)
- if c.has_section('object-updater'):
- conf = dict(c.items('object-updater'))
- else:
- print "Unable to find object-updater config section in %s." % \
- sys.argv[1]
- sys.exit(1)
+ once = len(sys.argv) > 2 and sys.argv[2] == 'once'
+ conf = utils.readconf(sys.argv[1], 'object-updater')
utils.drop_privileges(conf.get('user', 'swift'))
try:
diff --git a/bin/swift-proxy-server b/bin/swift-proxy-server
index c56df2e07..2ed1b5adf 100755
--- a/bin/swift-proxy-server
+++ b/bin/swift-proxy-server
@@ -20,5 +20,5 @@ from swift.common.wsgi import run_wsgi
if __name__ == '__main__':
if len(sys.argv) != 2:
- print "Usage: %s CONFIG_FILE"
- run_wsgi(sys.argv[1], default_port=80)
+ print "Usage: %s CONFIG_FILE" % sys.argv[0]
+ run_wsgi(sys.argv[1], 'proxy-server', default_port=80)