summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorChuck Thier <cthier@gmail.com>2010-08-20 00:42:38 +0000
committerChuck Thier <cthier@gmail.com>2010-08-20 00:42:38 +0000
commit2c596c0a0fbb0a1ec74092278d9f8844b90bf760 (patch)
tree89d9f398d91d6d3cdc6941788de8cb3b842f96ea /bin
parentdab46ea017a104a0965c547c08243d0a491e94e6 (diff)
downloadswift-2c596c0a0fbb0a1ec74092278d9f8844b90bf760.tar.gz
Initial commit of middleware refactor
Diffstat (limited to 'bin')
-rwxr-xr-xbin/swift-account-auditor9
-rwxr-xr-xbin/swift-account-reaper9
-rwxr-xr-xbin/swift-account-replicator9
-rwxr-xr-xbin/swift-account-server11
-rwxr-xr-xbin/swift-auth-server11
-rwxr-xr-xbin/swift-container-auditor9
-rwxr-xr-xbin/swift-container-replicator9
-rwxr-xr-xbin/swift-container-server11
-rwxr-xr-xbin/swift-container-updater7
-rwxr-xr-xbin/swift-object-auditor9
-rwxr-xr-xbin/swift-object-replicator37
-rwxr-xr-xbin/swift-object-server12
-rwxr-xr-xbin/swift-object-updater7
-rwxr-xr-xbin/swift-proxy-server32
14 files changed, 56 insertions, 126 deletions
diff --git a/bin/swift-account-auditor b/bin/swift-account-auditor
index 2bbb73c23..cba89e9e6 100755
--- a/bin/swift-account-auditor
+++ b/bin/swift-account-auditor
@@ -34,21 +34,20 @@ if __name__ == '__main__':
print "Unable to read config file."
sys.exit(1)
- server_conf = dict(c.items('account-server'))
if c.has_section('account-auditor'):
- auditor_conf = dict(c.items('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)
- logger = utils.get_logger(auditor_conf, 'account-auditor')
+ logger = utils.get_logger(conf)
# 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'))
+ utils.drop_privileges(conf.get('user', 'swift'))
try:
os.setsid()
@@ -62,7 +61,7 @@ if __name__ == '__main__':
signal.signal(signal.SIGTERM, kill_children)
- auditor = AccountAuditor(server_conf, auditor_conf)
+ auditor = AccountAuditor(conf)
if once:
auditor.audit_once()
else:
diff --git a/bin/swift-account-reaper b/bin/swift-account-reaper
index d62e43add..c5619d078 100755
--- a/bin/swift-account-reaper
+++ b/bin/swift-account-reaper
@@ -34,21 +34,20 @@ if __name__ == '__main__':
print "Unable to read config file."
sys.exit(1)
- server_conf = dict(c.items('account-server'))
if c.has_section('account-reaper'):
- reaper_conf = dict(c.items('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)
- logger = utils.get_logger(reaper_conf, 'account-reaper')
+ logger = utils.get_logger(conf)
# 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'))
+ utils.drop_privileges(conf.get('user', 'swift'))
try:
os.setsid()
@@ -62,7 +61,7 @@ if __name__ == '__main__':
signal.signal(signal.SIGTERM, kill_children)
- reaper = AccountReaper(server_conf, reaper_conf)
+ reaper = AccountReaper(conf)
if once:
reaper.reap_once()
else:
diff --git a/bin/swift-account-replicator b/bin/swift-account-replicator
index 3e47eaa4f..284c75159 100755
--- a/bin/swift-account-replicator
+++ b/bin/swift-account-replicator
@@ -41,17 +41,16 @@ if __name__ == '__main__':
sys.exit(1)
once = len(args) > 1 and args[1] == 'once'
- server_conf = dict(c.items('account-server'))
if c.has_section('account-replicator'):
- replicator_conf = dict(c.items('account-replicator'))
+ conf = dict(c.items('account-replicator'))
else:
print "Unable to find account-replicator config section in %s." % \
args[0]
sys.exit(1)
- utils.drop_privileges(server_conf.get('user', 'swift'))
+ utils.drop_privileges(conf.get('user', 'swift'))
if once or '--once' in [opt[0] for opt in optlist]:
- AccountReplicator(server_conf, replicator_conf).replicate_once()
+ AccountReplicator(conf).replicate_once()
else:
- AccountReplicator(server_conf, replicator_conf).replicate_forever()
+ AccountReplicator(conf).replicate_forever()
diff --git a/bin/swift-account-server b/bin/swift-account-server
index d5e802104..6be5706ea 100755
--- a/bin/swift-account-server
+++ b/bin/swift-account-server
@@ -14,17 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from ConfigParser import ConfigParser
import sys
from swift.common.wsgi import run_wsgi
-from swift.account.server import AccountController
if __name__ == '__main__':
- c = ConfigParser()
- if not c.read(sys.argv[1]):
- print "Unable to read config file."
- sys.exit(1)
- conf = dict(c.items('account-server'))
- run_wsgi(AccountController, conf, default_port=6002)
+ if len(sys.argv) != 2:
+ print "Usage: %s CONFIG_FILE"
+ run_wsgi(sys.argv[1], default_port=6002)
diff --git a/bin/swift-auth-server b/bin/swift-auth-server
index 775530e07..5f32912a9 100755
--- a/bin/swift-auth-server
+++ b/bin/swift-auth-server
@@ -14,17 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from ConfigParser import ConfigParser
import sys
from swift.common.wsgi import run_wsgi
-from swift.auth.server import AuthController
if __name__ == '__main__':
- c = ConfigParser()
- if not c.read(sys.argv[1]):
- print "Unable to read config file."
- sys.exit(1)
- conf = dict(c.items('auth-server'))
- run_wsgi(AuthController, conf, default_port=11000)
+ if len(sys.argv) != 2:
+ print "Usage: %s CONFIG_FILE"
+ run_wsgi(sys.argv[1], default_port=11000)
diff --git a/bin/swift-container-auditor b/bin/swift-container-auditor
index 1ff1682c5..6dfdc4592 100755
--- a/bin/swift-container-auditor
+++ b/bin/swift-container-auditor
@@ -34,21 +34,20 @@ if __name__ == '__main__':
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'))
+ 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')
+ logger = utils.get_logger(conf)
# 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'))
+ utils.drop_privileges(onf.get('user', 'swift'))
try:
os.setsid()
@@ -62,7 +61,7 @@ if __name__ == '__main__':
signal.signal(signal.SIGTERM, kill_children)
- auditor = ContainerAuditor(server_conf, auditor_conf)
+ auditor = ContainerAuditor(conf)
if once:
auditor.audit_once()
else:
diff --git a/bin/swift-container-replicator b/bin/swift-container-replicator
index db2ffc8b2..663cb51db 100755
--- a/bin/swift-container-replicator
+++ b/bin/swift-container-replicator
@@ -41,17 +41,16 @@ if __name__ == '__main__':
sys.exit(1)
once = len(args) > 1 and args[1] == 'once'
- server_conf = dict(c.items('container-server'))
if c.has_section('container-replicator'):
- replicator_conf = dict(c.items('container-replicator'))
+ conf = dict(c.items('container-replicator'))
else:
print "Unable to find container-replicator config section in %s." % \
args[0]
sys.exit(1)
- utils.drop_privileges(server_conf.get('user', 'swift'))
+ utils.drop_privileges(conf.get('user', 'swift'))
if once or '--once' in [opt[0] for opt in optlist]:
- ContainerReplicator(server_conf, replicator_conf).replicate_once()
+ ContainerReplicator(conf).replicate_once()
else:
- ContainerReplicator(server_conf, replicator_conf).replicate_forever()
+ ContainerReplicator(conf).replicate_forever()
diff --git a/bin/swift-container-server b/bin/swift-container-server
index e0ad813f4..f707eb091 100755
--- a/bin/swift-container-server
+++ b/bin/swift-container-server
@@ -14,17 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from ConfigParser import ConfigParser
import sys
from swift.common.wsgi import run_wsgi
-from swift.container.server import ContainerController
if __name__ == '__main__':
- c = ConfigParser()
- if not c.read(sys.argv[1]):
- print "Unable to read config file."
- sys.exit(1)
- conf = dict(c.items('container-server'))
- run_wsgi(ContainerController, conf, default_port=6001)
+ if len(sys.argv) != 2:
+ print "Usage: %s CONFIG_FILE"
+ run_wsgi(sys.argv[1], default_port=6001)
diff --git a/bin/swift-container-updater b/bin/swift-container-updater
index c37ba3680..7c2311512 100755
--- a/bin/swift-container-updater
+++ b/bin/swift-container-updater
@@ -34,15 +34,14 @@ if __name__ == '__main__':
print "Unable to read config file."
sys.exit(1)
- server_conf = dict(c.items('container-server'))
if c.has_section('container-updater'):
- updater_conf = dict(c.items('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)
- utils.drop_privileges(server_conf.get('user', 'swift'))
+ utils.drop_privileges(conf.get('user', 'swift'))
try:
os.setsid()
@@ -56,7 +55,7 @@ if __name__ == '__main__':
signal.signal(signal.SIGTERM, kill_children)
- updater = ContainerUpdater(server_conf, updater_conf)
+ updater = ContainerUpdater(conf)
if once:
updater.update_once_single_threaded()
else:
diff --git a/bin/swift-object-auditor b/bin/swift-object-auditor
index 5d0e54e66..e995ad872 100755
--- a/bin/swift-object-auditor
+++ b/bin/swift-object-auditor
@@ -34,21 +34,20 @@ if __name__ == '__main__':
print "Unable to read config file."
sys.exit(1)
- server_conf = dict(c.items('object-server'))
if c.has_section('object-auditor'):
- auditor_conf = dict(c.items('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)
- logger = utils.get_logger(auditor_conf, 'object-auditor')
+ logger = utils.get_logger(conf)
# 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'))
+ utils.drop_privileges(conf.get('user', 'swift'))
try:
os.setsid()
@@ -62,7 +61,7 @@ if __name__ == '__main__':
signal.signal(signal.SIGTERM, kill_children)
- auditor = ObjectAuditor(server_conf, auditor_conf)
+ auditor = ObjectAuditor(conf)
if once:
auditor.audit_once()
else:
diff --git a/bin/swift-object-replicator b/bin/swift-object-replicator
index 0de0b5d64..6a2da4b4f 100755
--- a/bin/swift-object-replicator
+++ b/bin/swift-object-replicator
@@ -27,38 +27,23 @@ from swift.common.utils import get_logger, drop_privileges, LoggerFileObject
TRUE_VALUES = set(('true', '1', 'yes', 'True', 'Yes'))
-def read_configs(conf_file):
+if __name__ == '__main__':
+ if len(sys.argv) < 2:
+ print "Usage: object-replicator CONFIG_FILE [once]"
+ sys.exit()
c = ConfigParser()
if not c.read(conf_file):
print "Unable to read config file: %s" % conf_file
sys.exit(1)
- conf = dict(c.items('object-server'))
- repl_conf = dict(c.items('object-replicator'))
- if not repl_conf:
- sys.exit()
- conf['replication_concurrency'] = repl_conf.get('concurrency',1)
- conf['vm_test_mode'] = repl_conf.get('vm_test_mode', 'no')
- conf['daemonize'] = repl_conf.get('daemonize', 'yes')
- conf['run_pause'] = repl_conf.get('run_pause', '30')
- conf['log_facility'] = repl_conf.get('log_facility', 'LOG_LOCAL1')
- conf['log_level'] = repl_conf.get('log_level', 'INFO')
- conf['timeout'] = repl_conf.get('timeout', '5')
- conf['stats_interval'] = repl_conf.get('stats_interval', '3600')
- conf['reclaim_age'] = int(repl_conf.get('reclaim_age', 86400))
-
- return conf
+ 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)
-if __name__ == '__main__':
- if len(sys.argv) < 2:
- print "Usage: object-replicator CONFIG_FILE [once]"
- sys.exit()
- try:
- conf = read_configs(sys.argv[1])
- except:
- print "Problem reading the config. Aborting object replication."
- sys.exit()
once = len(sys.argv) > 2 and sys.argv[2] == 'once'
- logger = get_logger(conf, 'object-replicator')
+ logger = get_logger(conf)
# log uncaught exceptions
sys.excepthook = lambda *exc_info: \
logger.critical('UNCAUGHT EXCEPTION', exc_info=exc_info)
diff --git a/bin/swift-object-server b/bin/swift-object-server
index c0603b96a..ce74b1719 100755
--- a/bin/swift-object-server
+++ b/bin/swift-object-server
@@ -14,17 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from ConfigParser import ConfigParser
import sys
from swift.common.wsgi import run_wsgi
-from swift.obj.server import ObjectController
if __name__ == '__main__':
- c = ConfigParser()
- if not c.read(sys.argv[1]):
- print "Unable to read config file."
- sys.exit(1)
- conf = dict(c.items('object-server'))
- run_wsgi(ObjectController, conf, default_port=6000)
-
+ if len(sys.argv) != 2:
+ print "Usage: %s CONFIG_FILE"
+ run_wsgi(sys.argv[1], default_port=6000)
diff --git a/bin/swift-object-updater b/bin/swift-object-updater
index 595840a07..a9512a4e7 100755
--- a/bin/swift-object-updater
+++ b/bin/swift-object-updater
@@ -34,15 +34,14 @@ if __name__ == '__main__':
print "Unable to read config file."
sys.exit(1)
- server_conf = dict(c.items('object-server'))
if c.has_section('object-updater'):
- updater_conf = dict(c.items('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)
- utils.drop_privileges(server_conf.get('user', 'swift'))
+ utils.drop_privileges(conf.get('user', 'swift'))
try:
os.setsid()
@@ -56,7 +55,7 @@ if __name__ == '__main__':
signal.signal(signal.SIGTERM, kill_children)
- updater = ObjectUpdater(server_conf, updater_conf)
+ updater = ObjectUpdater(conf)
if once:
updater.update_once_single_threaded()
else:
diff --git a/bin/swift-proxy-server b/bin/swift-proxy-server
index 0ba14e235..c56df2e07 100755
--- a/bin/swift-proxy-server
+++ b/bin/swift-proxy-server
@@ -14,37 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from ConfigParser import ConfigParser
-import os
import sys
from swift.common.wsgi import run_wsgi
-from swift.common.auth import DevAuthMiddleware
-from swift.common.memcached import MemcacheRing
-from swift.common.utils import get_logger
-from swift.proxy.server import Application
if __name__ == '__main__':
- c = ConfigParser()
- if not c.read(sys.argv[1]):
- print "Unable to read config file."
- sys.exit(1)
- conf = dict(c.items('proxy-server'))
- if c.has_section('auth-server'):
- auth_conf = dict(c.items('auth-server'))
- else:
- auth_conf = {}
- swift_dir = conf.get('swift_dir', '/etc/swift')
- m, c = auth_conf.get('class',
- 'swift.common.auth.DevAuthMiddleware').rsplit('.', 1)
- m = __import__(m, fromlist=[c])
- authware = m.__dict__[c]
-
- memcache = MemcacheRing([s.strip() for s in
- conf.get('memcache_servers', '127.0.0.1:11211').split(',')
- if s.strip()])
- logger = get_logger(conf, 'proxy')
- app = Application(conf, memcache, logger)
- # Wrap the app with auth
- app = authware(app, auth_conf, memcache, logger)
- run_wsgi(app, conf, logger=logger, default_port=80)
+ if len(sys.argv) != 2:
+ print "Usage: %s CONFIG_FILE"
+ run_wsgi(sys.argv[1], default_port=80)