Refactored logging configuration so that it has sane defaults

This commit is contained in:
Chuck Thier 2010-08-24 13:41:58 +00:00
parent 85e043e9a2
commit c62707ae72
25 changed files with 254 additions and 304 deletions

View File

@ -24,23 +24,12 @@ from swift.common import utils
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) < 2: if len(sys.argv) < 2:
print "Usage: account-auditor CONFIG_FILE [once]" print "Usage: swift-account-auditor CONFIG_FILE [once]"
sys.exit() sys.exit()
once = len(sys.argv) > 2 and sys.argv[2] == 'once' once = len(sys.argv) > 2 and sys.argv[2] == 'once'
c = ConfigParser() conf = utils.readconf(sys.argv[1], 'account-auditor')
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)
logger = utils.get_logger(conf) logger = utils.get_logger(conf)
# log uncaught exceptions # log uncaught exceptions
sys.excepthook = lambda *exc_info: \ sys.excepthook = lambda *exc_info: \

View File

@ -29,18 +29,7 @@ if __name__ == '__main__':
once = len(sys.argv) > 2 and sys.argv[2] == 'once' once = len(sys.argv) > 2 and sys.argv[2] == 'once'
c = ConfigParser() conf = utils.readconf(sys.argv[1], 'account-reaper')
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)
logger = utils.get_logger(conf) logger = utils.get_logger(conf)
# log uncaught exceptions # log uncaught exceptions
sys.excepthook = lambda *exc_info: \ sys.excepthook = lambda *exc_info: \

View File

@ -32,22 +32,11 @@ if __name__ == '__main__':
optlist, args = getopt.getopt(sys.argv[1:], '', ['once']) optlist, args = getopt.getopt(sys.argv[1:], '', ['once'])
if not args: if not args:
print "Usage: account-replicator <--once> CONFIG_FILE [once]" print "Usage: swift-account-replicator <--once> CONFIG_FILE [once]"
sys.exit() 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' once = len(args) > 1 and args[1] == 'once'
conf = utils.readconf(sys.argv[1], 'account-replicator')
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)
utils.drop_privileges(conf.get('user', 'swift')) utils.drop_privileges(conf.get('user', 'swift'))
if once or '--once' in [opt[0] for opt in optlist]: if once or '--once' in [opt[0] for opt in optlist]:
AccountReplicator(conf).replicate_once() AccountReplicator(conf).replicate_once()

View File

@ -20,6 +20,6 @@ from swift.common.wsgi import run_wsgi
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) != 2: if len(sys.argv) != 2:
print "Usage: %s CONFIG_FILE" print "Usage: %s CONFIG_FILE" % sys.argv[0]
run_wsgi(sys.argv[1], default_port=6002) run_wsgi(sys.argv[1], 'account-server', default_port=6002)

View File

@ -20,6 +20,6 @@ from swift.common.wsgi import run_wsgi
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) != 2: if len(sys.argv) != 2:
print "Usage: %s CONFIG_FILE" print "Usage: %s CONFIG_FILE" % sys.argv[0]
run_wsgi(sys.argv[1], default_port=11000) run_wsgi(sys.argv[1], 'auth-server', default_port=11000)

View File

@ -24,23 +24,12 @@ from swift.common import utils
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) < 2: if len(sys.argv) < 2:
print "Usage: container-auditor CONFIG_FILE [once]" print "Usage: swift-container-auditor CONFIG_FILE [once]"
sys.exit() sys.exit()
once = len(sys.argv) > 2 and sys.argv[2] == 'once' once = len(sys.argv) > 2 and sys.argv[2] == 'once'
c = ConfigParser() conf = utils.readconf(sys.argv[1], 'container-auditor')
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)
logger = utils.get_logger(conf) logger = utils.get_logger(conf)
# log uncaught exceptions # log uncaught exceptions
sys.excepthook = lambda *exc_info: \ sys.excepthook = lambda *exc_info: \

View File

@ -32,22 +32,11 @@ if __name__ == '__main__':
optlist, args = getopt.getopt(sys.argv[1:], '', ['once']) optlist, args = getopt.getopt(sys.argv[1:], '', ['once'])
if not args: if not args:
print "Usage: container-replicator <--once> CONFIG_FILE [once]" print "Usage: swift-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) sys.exit(1)
once = len(args) > 1 and args[1] == 'once' once = len(args) > 1 and args[1] == 'once'
conf = utils.readconf(args[0], 'container-replicator')
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]
sys.exit(1)
utils.drop_privileges(conf.get('user', 'swift')) utils.drop_privileges(conf.get('user', 'swift'))
if once or '--once' in [opt[0] for opt in optlist]: if once or '--once' in [opt[0] for opt in optlist]:
ContainerReplicator(conf).replicate_once() ContainerReplicator(conf).replicate_once()

View File

@ -20,6 +20,5 @@ from swift.common.wsgi import run_wsgi
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) != 2: if len(sys.argv) != 2:
print "Usage: %s CONFIG_FILE" print "Usage: %s CONFIG_FILE" % sys.argv[0]
run_wsgi(sys.argv[1], default_port=6001) run_wsgi(sys.argv[1], 'container-server', default_port=6001)

View File

@ -24,23 +24,11 @@ from swift.common import utils
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) < 2: if len(sys.argv) < 2:
print "Usage: container-updater CONFIG_FILE [once]" print "Usage: swift-container-updater CONFIG_FILE [once]"
sys.exit() sys.exit()
once = len(sys.argv) > 2 and sys.argv[2] == 'once' once = len(sys.argv) > 2 and sys.argv[2] == 'once'
conf = readconf(sys.argv[1], 'container-updater')
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)
utils.drop_privileges(conf.get('user', 'swift')) utils.drop_privileges(conf.get('user', 'swift'))
try: try:

View File

@ -17,30 +17,17 @@
import os import os
import signal import signal
import sys import sys
from ConfigParser import ConfigParser
from swift.obj.auditor import ObjectAuditor from swift.obj.auditor import ObjectAuditor
from swift.common import utils from swift.common import utils
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) < 2: if len(sys.argv) < 2:
print "Usage: object-auditor CONFIG_FILE [once]" print "Usage: swift-object-auditor CONFIG_FILE [once]"
sys.exit() sys.exit()
once = len(sys.argv) > 2 and sys.argv[2] == 'once' once = len(sys.argv) > 2 and sys.argv[2] == 'once'
conf = utils.readconf(sys.argv[1], 'object-auditor')
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)
logger = utils.get_logger(conf) logger = utils.get_logger(conf)
# log uncaught exceptions # log uncaught exceptions
sys.excepthook = lambda *exc_info: \ sys.excepthook = lambda *exc_info: \

View File

@ -15,7 +15,6 @@
# limitations under the License. # limitations under the License.
import sys import sys
from ConfigParser import ConfigParser
import logging import logging
import time import time
@ -23,25 +22,16 @@ from eventlet import sleep, hubs
hubs.use_hub('poll') hubs.use_hub('poll')
from swift.obj.replicator import ObjectReplicator 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')) TRUE_VALUES = set(('true', '1', 'yes', 'True', 'Yes'))
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) < 2: if len(sys.argv) < 2:
print "Usage: object-replicator CONFIG_FILE [once]" print "Usage: swift-object-replicator CONFIG_FILE [once]"
sys.exit() sys.exit()
c = ConfigParser() conf = readconf(sys.argv[1], "object-replicator")
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)
once = len(sys.argv) > 2 and sys.argv[2] == 'once' once = len(sys.argv) > 2 and sys.argv[2] == 'once'
logger = get_logger(conf) logger = get_logger(conf)
# log uncaught exceptions # log uncaught exceptions

View File

@ -20,5 +20,5 @@ from swift.common.wsgi import run_wsgi
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) != 2: if len(sys.argv) != 2:
print "Usage: %s CONFIG_FILE" print "Usage: %s CONFIG_FILE" % sys.argv[0]
run_wsgi(sys.argv[1], default_port=6000) run_wsgi(sys.argv[1], 'object-server', default_port=6000)

View File

@ -17,30 +17,18 @@
import os import os
import signal import signal
import sys import sys
from ConfigParser import ConfigParser
from swift.obj.updater import ObjectUpdater from swift.obj.updater import ObjectUpdater
from swift.common import utils from swift.common import utils
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) < 2: if len(sys.argv) < 2:
print "Usage: object-updater CONFIG_FILE [once]" print "Usage: swift-object-updater CONFIG_FILE [once]"
sys.exit() sys.exit(1)
once = len(sys.argv) > 2 and sys.argv[2] == 'once' once = len(sys.argv) > 2 and sys.argv[2] == 'once'
c = ConfigParser() conf = utils.readconf(sys.argv[1], 'object-updater')
if not c.read(sys.argv[1]):
print "Unable to read config file."
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)
utils.drop_privileges(conf.get('user', 'swift')) utils.drop_privileges(conf.get('user', 'swift'))
try: try:

View File

@ -20,5 +20,5 @@ from swift.common.wsgi import run_wsgi
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) != 2: if len(sys.argv) != 2:
print "Usage: %s CONFIG_FILE" print "Usage: %s CONFIG_FILE" % sys.argv[0]
run_wsgi(sys.argv[1], default_port=80) run_wsgi(sys.argv[1], 'proxy-server', default_port=80)

View File

@ -152,9 +152,6 @@ The following configuration options are available:
================== ========== ============================================= ================== ========== =============================================
Option Default Description Option Default Description
------------------ ---------- --------------------------------------------- ------------------ ---------- ---------------------------------------------
log_name swift Label used when logging
log_facility LOG_LOCAL0 Syslog log facility
log_level INFO Logging level
swift_dir /etc/swift Swift configuration directory swift_dir /etc/swift Swift configuration directory
devices /srv/node Parent directory of where devices are mounted devices /srv/node Parent directory of where devices are mounted
mount_check true Weather or not check if the devices are mount_check true Weather or not check if the devices are
@ -167,63 +164,75 @@ workers 1 Number of workers to fork
[object-server] [object-server]
================== ========== ============================================= ================== ============= ===========================================
Option Default Description Option Default Description
------------------ ---------- --------------------------------------------- ------------------ ------------- -------------------------------------------
use paste.deploy entrypoint for the object use paste.deploy entrypoint for the object
server. For most cases, this should be server. For most cases, this should be
`egg:swift#object`. `egg:swift#object`.
log_requests True Weather or not to log each request log_name object-server Label used when logging
user swift User to run as log_facility LOG_LOCAL0 Syslog log facility
node_timeout 3 Request timeout to external services log_level INFO Logging level
conn_timeout 0.5 Connection timeout to external services log_requests True Weather or not to log each request
network_chunk_size 65536 Size of chunks to read/write over the user swift User to run as
network node_timeout 3 Request timeout to external services
disk_chunk_size 65536 Size of chunks to read/write to disk conn_timeout 0.5 Connection timeout to external services
max_upload_time 86400 Maximum time allowed to upload an object network_chunk_size 65536 Size of chunks to read/write over the
slow 0 If > 0, Minimum time in seconds for a PUT network
or DELETE request to complete disk_chunk_size 65536 Size of chunks to read/write to disk
================== ========== ============================================= max_upload_time 86400 Maximum time allowed to upload an object
slow 0 If > 0, Minimum time in seconds for a PUT
or DELETE request to complete
================== ============= ===========================================
[object-replicator] [object-replicator]
================== ========== =========================================== ================== ================= =======================================
Option Default Description Option Default Description
------------------ ---------- ------------------------------------------- ------------------ ----------------- ---------------------------------------
daemonize yes Weather or not to run replication as a log_name object-replicator Label used when logging
daemon log_facility LOG_LOCAL0 Syslog log facility
run_pause 30 Time in seconds to wait between replication log_level INFO Logging level
passes daemonize yes Weather or not to run replication as a
concurrency 1 Number of replication workers to spawn daemon
timeout 5 Timeout value sent to rsync --timeout and run_pause 30 Time in seconds to wait between
--contimeout options replication passes
stats_interval 3600 Interval in seconds between logging concurrency 1 Number of replication workers to spawn
replication statistics timeout 5 Timeout value sent to rsync --timeout
reclaim_age 604800 Time elapsed in seconds before an object and --contimeout options
can be reclaimed stats_interval 3600 Interval in seconds between logging
================== ========== =========================================== replication statistics
reclaim_age 604800 Time elapsed in seconds before an
object can be reclaimed
================== ================= =======================================
[object-updater] [object-updater]
================== ========== =========================================== ================== ============== ==========================================
Option Default Description Option Default Description
------------------ ---------- ------------------------------------------- ------------------ -------------- ------------------------------------------
interval 300 Minimum time for a pass to take log_name object-updater Label used when logging
concurrency 1 Number of updater workers to spawn log_facility LOG_LOCAL0 Syslog log facility
node_timeout 10 Request timeout to external services log_level INFO Logging level
conn_timeout 0.5 Connection timeout to external services interval 300 Minimum time for a pass to take
slowdown 0.01 Time in seconds to wait between objects concurrency 1 Number of updater workers to spawn
================== ========== =========================================== node_timeout 10 Request timeout to external services
conn_timeout 0.5 Connection timeout to external services
slowdown 0.01 Time in seconds to wait between objects
================== ============== ==========================================
[object-auditor] [object-auditor]
================== ========== =========================================== ================== ============== ==========================================
Option Default Description Option Default Description
------------------ ---------- ------------------------------------------- ------------------ -------------- ------------------------------------------
interval 1800 Minimum time for a pass to take log_name object-auditor Label used when logging
node_timeout 10 Request timeout to external services log_facility LOG_LOCAL0 Syslog log facility
conn_timeout 0.5 Connection timeout to external services log_level INFO Logging level
================== ========== =========================================== interval 1800 Minimum time for a pass to take
node_timeout 10 Request timeout to external services
conn_timeout 0.5 Connection timeout to external services
================== ============== ==========================================
------------------------------ ------------------------------
Container Server Configuration Container Server Configuration
@ -239,9 +248,6 @@ The following configuration options are available:
================== ========== ============================================ ================== ========== ============================================
Option Default Description Option Default Description
------------------ ---------- -------------------------------------------- ------------------ ---------- --------------------------------------------
log_name swift Label used when logging
log_facility LOG_LOCAL0 Syslog log facility
log_level INFO Logging level
swift_dir /etc/swift Swift configuration directory swift_dir /etc/swift Swift configuration directory
devices /srv/node Parent irectory of where devices are mounted devices /srv/node Parent irectory of where devices are mounted
mount_check true Weather or not check if the devices are mount_check true Weather or not check if the devices are
@ -255,52 +261,67 @@ user swift User to run as
[container-server] [container-server]
================== ========== ============================================ ================== ================ ========================================
Option Default Description Option Default Description
------------------ ---------- -------------------------------------------- ------------------ ---------------- ----------------------------------------
use paste.deploy entrypoint for the container use paste.deploy entrypoint for the container
server. For most cases, this should be server. For most cases, this should be
`egg:swift#container`. `egg:swift#container`.
node_timeout 3 Request timeout to external services log_name container-server Label used when logging
conn_timeout 0.5 Connection timeout to external services log_facility LOG_LOCAL0 Syslog log facility
================== ========== ============================================ log_level INFO Logging level
node_timeout 3 Request timeout to external services
conn_timeout 0.5 Connection timeout to external services
================== ================ ========================================
[container-replicator] [container-replicator]
================== ========== =========================================== ================== ==================== ====================================
Option Default Description Option Default Description
------------------ ---------- ------------------------------------------- ------------------ -------------------- ------------------------------------
log_name container-replicator Label used when logging
log_facility LOG_LOCAL0 Syslog log facility
log_level INFO Logging level
per_diff 1000 per_diff 1000
concurrency 8 Number of replication workers to spawn concurrency 8 Number of replication workers to
run_pause 30 Time in seconds to wait between replication spawn
passes run_pause 30 Time in seconds to wait between
node_timeout 10 Request timeout to external services replication passes
conn_timeout 0.5 Connection timeout to external services node_timeout 10 Request timeout to external services
reclaim_age 604800 Time elapsed in seconds before a container conn_timeout 0.5 Connection timeout to external
can be reclaimed services
================== ========== =========================================== reclaim_age 604800 Time elapsed in seconds before a
container can be reclaimed
================== ==================== ====================================
[container-updater] [container-updater]
================== ========== =========================================== ================== ================= =======================================
Option Default Description Option Default Description
------------------ ---------- ------------------------------------------- ------------------ ----------------- ---------------------------------------
interval 300 Minimum time for a pass to take log_name container-updater Label used when logging
concurrency 4 Number of updater workers to spawn log_facility LOG_LOCAL0 Syslog log facility
node_timeout 3 Request timeout to external services log_level INFO Logging level
conn_timeout 0.5 Connection timeout to external services interval 300 Minimum time for a pass to take
slowdown 0.01 Time in seconds to wait between containers concurrency 4 Number of updater workers to spawn
================== ========== =========================================== node_timeout 3 Request timeout to external services
conn_timeout 0.5 Connection timeout to external services
slowdown 0.01 Time in seconds to wait between
containers
================== ================= =======================================
[container-auditor] [container-auditor]
================== ========== =========================================== ================== ================= =======================================
Option Default Description Option Default Description
------------------ ---------- ------------------------------------------- ------------------ ----------------- ---------------------------------------
interval 1800 Minimum time for a pass to take log_name container-auditor Label used when logging
node_timeout 10 Request timeout to external services log_facility LOG_LOCAL0 Syslog log facility
conn_timeout 0.5 Connection timeout to external services log_level INFO Logging level
================== ========== =========================================== interval 1800 Minimum time for a pass to take
node_timeout 10 Request timeout to external services
conn_timeout 0.5 Connection timeout to external services
================== ================= =======================================
---------------------------- ----------------------------
Account Server Configuration Account Server Configuration
@ -316,9 +337,6 @@ The following configuration options are available:
================== ========== ============================================= ================== ========== =============================================
Option Default Description Option Default Description
------------------ ---------- --------------------------------------------- ------------------ ---------- ---------------------------------------------
log_name swift Label used when logging
log_facility LOG_LOCAL0 Syslog log facility
log_level INFO Logging level
swift_dir /etc/swift Swift configuration directory swift_dir /etc/swift Swift configuration directory
devices /srv/node Parent directory or where devices are mounted devices /srv/node Parent directory or where devices are mounted
mount_check true Weather or not check if the devices are mount_check true Weather or not check if the devices are
@ -332,57 +350,63 @@ user swift User to run as
[account-server] [account-server]
================== ========== ============================================= ================== ============== ==========================================
Option Default Description Option Default Description
------------------ ---------- --------------------------------------------- ------------------ -------------- ------------------------------------------
use paste.deploy entrypoint for the account use paste.deploy entrypoint for the account
server. For most cases, this should be server. For most cases, this should be
`egg:swift#account`. `egg:swift#account`.
================== ========== ============================================= log_name account-server Label used when logging
log_facility LOG_LOCAL0 Syslog log facility
log_level INFO Logging level
================== ============== ==========================================
[account-replicator] [account-replicator]
================== ========== =========================================== ================== ================== ======================================
Option Default Description Option Default Description
------------------ ---------- ------------------------------------------- ------------------ ------------------ --------------------------------------
log_facility LOG_LOCAL0 Syslog log facility log_name account-replicator Label used when logging
log_level INFO Logging level log_facility LOG_LOCAL0 Syslog log facility
log_level INFO Logging level
per_diff 1000 per_diff 1000
concurrency 8 Number of replication workers to spawn concurrency 8 Number of replication workers to spawn
run_pause 30 Time in seconds to wait between replication run_pause 30 Time in seconds to wait between
passes replication passes
node_timeout 10 Request timeout to external services node_timeout 10 Request timeout to external services
conn_timeout 0.5 Connection timeout to external services conn_timeout 0.5 Connection timeout to external services
reclaim_age 604800 Time elapsed in seconds before a account reclaim_age 604800 Time elapsed in seconds before an
can be reclaimed account can be reclaimed
================== ========== =========================================== ================== ================== ======================================
[account-auditor] [account-auditor]
==================== ========== =========================================== ==================== =============== =======================================
Option Default Description Option Default Description
-------------------- ---------- ------------------------------------------- -------------------- --------------- ---------------------------------------
log_facility LOG_LOCAL0 Syslog log facility log_name account-auditor Label used when logging
log_level INFO Logging level log_facility LOG_LOCAL0 Syslog log facility
interval 1800 Minimum time for a pass to take log_level INFO Logging level
max_container_count 100 Maximum containers randomly picked for interval 1800 Minimum time for a pass to take
a given account audit max_container_count 100 Maximum containers randomly picked for
node_timeout 10 Request timeout to external services a given account audit
conn_timeout 0.5 Connection timeout to external services node_timeout 10 Request timeout to external services
==================== ========== =========================================== conn_timeout 0.5 Connection timeout to external services
==================== =============== =======================================
[account-reaper] [account-reaper]
================== ========== =========================================== ================== =============== =========================================
Option Default Description Option Default Description
------------------ ---------- ------------------------------------------- ------------------ --------------- -----------------------------------------
log_facility LOG_LOCAL0 Syslog log facility log_name account-auditor Label used when logging
log_level INFO Logging level log_facility LOG_LOCAL0 Syslog log facility
concurrency 25 Number of replication workers to spawn log_level INFO Logging level
interval 3600 Minimum time for a pass to take concurrency 25 Number of replication workers to spawn
node_timeout 10 Request timeout to external services interval 3600 Minimum time for a pass to take
conn_timeout 0.5 Connection timeout to external services node_timeout 10 Request timeout to external services
================== ========== =========================================== conn_timeout 0.5 Connection timeout to external services
================== =============== =========================================
-------------------------- --------------------------
Proxy Server Configuration Proxy Server Configuration
@ -393,8 +417,6 @@ Proxy Server Configuration
============================ =============== ============================= ============================ =============== =============================
Option Default Description Option Default Description
---------------------------- --------------- ----------------------------- ---------------------------- --------------- -----------------------------
log_facility LOG_LOCAL0 Syslog log facility
log_level INFO Log level
bind_ip 0.0.0.0 IP Address for server to bind_ip 0.0.0.0 IP Address for server to
bind to bind to
bind_port 80 Port for server to bind to bind_port 80 Port for server to bind to
@ -414,6 +436,9 @@ use paste.deploy entrypoint for
the proxy server. For most the proxy server. For most
cases, this should be cases, this should be
`egg:swift#proxy`. `egg:swift#proxy`.
log_name proxy-server Label used when logging
log_facility LOG_LOCAL0 Syslog log facility
log_level INFO Log level
log_headers True If True, log headers in each log_headers True If True, log headers in each
request request
recheck_account_existence 60 Cache timeout in seconds to recheck_account_existence 60 Cache timeout in seconds to

View File

@ -1,7 +1,4 @@
[DEFAULT] [DEFAULT]
log_name = account
# log_facility = LOG_LOCAL0
# log_level = INFO
# bind_ip = 0.0.0.0 # bind_ip = 0.0.0.0
# bind_port = 6002 # bind_port = 6002
# workers = 1 # workers = 1
@ -15,9 +12,12 @@ pipeline = account-server
[app:account-server] [app:account-server]
use = egg:swift#account use = egg:swift#account
# log_name = account-server
# log_facility = LOG_LOCAL0
# log_level = INFO
[account-replicator] [account-replicator]
log_name = account-replicator # log_name = account-replicator
# log_facility = LOG_LOCAL0 # log_facility = LOG_LOCAL0
# log_level = INFO # log_level = INFO
# per_diff = 1000 # per_diff = 1000
@ -34,7 +34,7 @@ log_name = account-replicator
# reclaim_age = 86400 # reclaim_age = 86400
[account-stats] [account-stats]
log_name = account-stats # log_name = account-stats
# cf_account = AUTH_7abbc116-8a07-4b63-819d-02715d3e0f31 # cf_account = AUTH_7abbc116-8a07-4b63-819d-02715d3e0f31
# container_name = account_stats # container_name = account_stats
# proxy_server_conf = /etc/swift/proxy-server.conf # proxy_server_conf = /etc/swift/proxy-server.conf
@ -42,7 +42,7 @@ log_name = account-stats
# log_level = INFO # log_level = INFO
[account-auditor] [account-auditor]
log_name = account-auditor # log_name = account-auditor
# Will audit, at most, 1 account per device per interval # Will audit, at most, 1 account per device per interval
# interval = 1800 # interval = 1800
# Maximum containers randomly picked for a given account audit # Maximum containers randomly picked for a given account audit
@ -53,7 +53,7 @@ log_name = account-auditor
# log_level = INFO # log_level = INFO
[account-reaper] [account-reaper]
log_name = account-reaper # log_name = account-reaper
# concurrency = 25 # concurrency = 25
# interval = 3600 # interval = 3600
# node_timeout = 10 # node_timeout = 10

View File

@ -1,9 +1,6 @@
[DEFAULT] [DEFAULT]
log_name = auth
# bind_ip = 0.0.0.0 # bind_ip = 0.0.0.0
# bind_port = 11000 # bind_port = 11000
# log_facility = LOG_LOCAL0
# log_level = INFO
# workers = 1 # workers = 1
# user = swift # user = swift
# swift_dir = /etc/swift # swift_dir = /etc/swift
@ -15,6 +12,9 @@ pipeline = auth-server
[app:auth-server] [app:auth-server]
use = egg:swift#auth use = egg:swift#auth
# log_name = auth-server
# log_facility = LOG_LOCAL0
# log_level = INFO
# reseller_prefix = AUTH # reseller_prefix = AUTH
# default_cluster_url = http://127.0.0.1:9000/v1 # default_cluster_url = http://127.0.0.1:9000/v1
# token_life = 86400 # token_life = 86400

View File

@ -1,7 +1,4 @@
[DEFAULT] [DEFAULT]
log_name = container
# log_facility = LOG_LOCAL0
# log_level = INFO
# bind_ip = 0.0.0.0 # bind_ip = 0.0.0.0
# bind_port = 6001 # bind_port = 6001
# workers = 1 # workers = 1
@ -15,11 +12,14 @@ pipeline = container-server
[app:container-server] [app:container-server]
use = egg:swift#container use = egg:swift#container
# log_name = container-server
# log_facility = LOG_LOCAL0
# log_level = INFO
# node_timeout = 3 # node_timeout = 3
# conn_timeout = 0.5 # conn_timeout = 0.5
[container-replicator] [container-replicator]
log_name = container-replicator # log_name = container-replicator
# per_diff = 1000 # per_diff = 1000
# concurrency = 8 # concurrency = 8
# run_pause = 30 # run_pause = 30
@ -29,7 +29,7 @@ log_name = container-replicator
# reclaim_age = 604800 # reclaim_age = 604800
[container-updater] [container-updater]
log_name = container-updater # log_name = container-updater
# interval = 300 # interval = 300
# concurrency = 4 # concurrency = 4
# node_timeout = 3 # node_timeout = 3
@ -38,7 +38,7 @@ log_name = container-updater
# slowdown = 0.01 # slowdown = 0.01
[container-auditor] [container-auditor]
log_name = container-auditor # log_name = container-auditor
# Will audit, at most, 1 container per device per interval # Will audit, at most, 1 container per device per interval
# interval = 1800 # interval = 1800
# Maximum objects randomly picked for a given container audit # Maximum objects randomly picked for a given container audit

View File

@ -1,7 +1,4 @@
[DEFAULT] [DEFAULT]
log_name = object
# log_facility = LOG_LOCAL0
# log_level = INFO
# bind_ip = 0.0.0.0 # bind_ip = 0.0.0.0
# bind_port = 6000 # bind_port = 6000
# workers = 1 # workers = 1
@ -15,6 +12,9 @@ pipeline = object-server
[app:object-server] [app:object-server]
use = egg:swift#object use = egg:swift#object
# log_name = object-server
# log_facility = LOG_LOCAL0
# log_level = INFO
# log_requests = True # log_requests = True
# node_timeout = 3 # node_timeout = 3
# conn_timeout = 0.5 # conn_timeout = 0.5
@ -24,7 +24,7 @@ use = egg:swift#object
# slow = 1 # slow = 1
[object-replicator] [object-replicator]
log_name = object-replicator # log_name = object-replicator
# daemonize = on # daemonize = on
# run_pause = 30 # run_pause = 30
# concurrency = 1 # concurrency = 1
@ -34,7 +34,7 @@ log_name = object-replicator
# reclaim_age = 604800 # reclaim_age = 604800
[object-updater] [object-updater]
log_name = object-updater # log_name = object-updater
# interval = 300 # interval = 300
# concurrency = 1 # concurrency = 1
# node_timeout = 10 # node_timeout = 10
@ -43,7 +43,7 @@ log_name = object-updater
# slowdown = 0.01 # slowdown = 0.01
[object-auditor] [object-auditor]
log_name = object-auditor # log_name = object-auditor
# Will audit, at most, 1 object per device per interval # Will audit, at most, 1 object per device per interval
# interval = 1800 # interval = 1800
# node_timeout = 10 # node_timeout = 10

View File

@ -1,7 +1,4 @@
[DEFAULT] [DEFAULT]
log_name = proxy
# log_facility = LOG_LOCAL0
# log_level = INFO
# bind_ip = 0.0.0.0 # bind_ip = 0.0.0.0
# bind_port = 80 # bind_port = 80
# swift_dir = /etc/swift # swift_dir = /etc/swift
@ -15,6 +12,9 @@ pipeline = healthcheck cache auth proxy
[app:proxy] [app:proxy]
use = egg:swift#proxy use = egg:swift#proxy
# log_name = proxy-server
# log_facility = LOG_LOCAL0
# log_level = INFO
# log_headers = False # log_headers = False
# recheck_account_existence = 60 # recheck_account_existence = 60
# recheck_container_existence = 60 # recheck_container_existence = 60

View File

@ -105,6 +105,8 @@ class DevAuthMiddleware(object):
return True return True
def filter_factory(global_conf, **local_conf): def filter_factory(global_conf, **local_conf):
conf = global_conf.copy()
conf.update(local_conf)
def auth_filter(app): def auth_filter(app):
return DevAuthMiddleware(app, local_conf) return DevAuthMiddleware(app, conf)
return auth_filter return auth_filter

View File

@ -29,6 +29,8 @@ class CacheMiddleware(object):
return self.app(env, start_response) return self.app(env, start_response)
def filter_factory(global_conf, **local_conf): def filter_factory(global_conf, **local_conf):
conf = global_conf.copy()
conf.update(local_conf)
def cache_filter(app): def cache_filter(app):
return CacheMiddleware(app, local_conf) return CacheMiddleware(app, conf)
return cache_filter return cache_filter

View File

@ -31,6 +31,7 @@ import ctypes
import ctypes.util import ctypes.util
import fcntl import fcntl
import struct import struct
from ConfigParser import ConfigParser
import eventlet import eventlet
from eventlet import greenio, GreenPool, sleep, Timeout, listen from eventlet import greenio, GreenPool, sleep, Timeout, listen
@ -331,6 +332,7 @@ def get_logger(conf, name=None):
log_facility = LOG_LOCAL0 log_facility = LOG_LOCAL0
log_level = INFO log_level = INFO
log_name = swift
:param conf: Configuration dict to read settings from :param conf: Configuration dict to read settings from
:param name: Name of the logger :param name: Name of the logger
@ -345,7 +347,8 @@ def get_logger(conf, name=None):
if name is None: if name is None:
name = conf.get('log_name', 'swift') name = conf.get('log_name', 'swift')
get_logger.handler = SysLogHandler(address='/dev/log', get_logger.handler = SysLogHandler(address='/dev/log',
facility=getattr(SysLogHandler, conf.get('log_facility', 'LOG_LOCAL0'), facility=getattr(SysLogHandler,
conf.get('log_facility', 'LOG_LOCAL0'),
SysLogHandler.LOG_LOCAL0)) SysLogHandler.LOG_LOCAL0))
root_logger.addHandler(get_logger.handler) root_logger.addHandler(get_logger.handler)
root_logger.setLevel( root_logger.setLevel(
@ -524,3 +527,20 @@ def item_from_env(env, item_name):
def cache_from_env(env): def cache_from_env(env):
return item_from_env(env, 'swift.cache') return item_from_env(env, 'swift.cache')
def readconf(conf, section_name, log_name=None):
c = ConfigParser()
if not c.read(conf):
print "Unable to read config file %s" % conf
sys.exit(1)
if c.has_section(section_name):
conf = dict(c.items(section_name))
else:
print "Unable to find %s config section in %s" % (section_name, conf)
sys.exit(1)
if "log_name" not in conf:
if log_name is not None:
conf['log_name'] = log_name
else:
conf['log_name'] = section_name
return conf

View File

@ -59,25 +59,27 @@ def monkey_patch_mimetools():
# We might be able to pull pieces of this out to test, but right now it seems # We might be able to pull pieces of this out to test, but right now it seems
# like more work than it's worth. # like more work than it's worth.
def run_wsgi(conf_file, *args, **kwargs): # pragma: no cover def run_wsgi(conf_file, app_section, *args, **kwargs): # pragma: no cover
""" """
Loads common settings from conf, then instantiates app and runs Loads common settings from conf, then instantiates app and runs
the server using the specified number of workers. the server using the specified number of workers.
:param conf_file: Path to paste.deploy style configuration file :param conf_file: Path to paste.deploy style configuration file
:param app_section: App name from conf file to load config from
""" """
try: try:
app = loadapp('config:%s' % conf_file) conf = appconfig('config:%s' % conf_file, name=app_section)
conf = appconfig('config:%s' % conf_file) log_name = conf.get('log_name', app_section)
app = loadapp('config:%s' % conf_file,
global_conf={'log_name':log_name})
except Exception, e: except Exception, e:
print "Error trying to load config %s: %s" % (conf_file, e) print "Error trying to load config %s: %s" % (conf_file, e)
return return
if 'logger' in kwargs: if 'logger' in kwargs:
logger = kwargs['logger'] logger = kwargs['logger']
else: else:
logger = get_logger(conf) logger = get_logger(conf, log_name)
# log uncaught exceptions # log uncaught exceptions
sys.excepthook = lambda * exc_info: \ sys.excepthook = lambda * exc_info: \
logger.critical('UNCAUGHT EXCEPTION', exc_info=exc_info) logger.critical('UNCAUGHT EXCEPTION', exc_info=exc_info)

View File

@ -1264,5 +1264,7 @@ class Application(BaseApplication):
return None return None
def app_factory(global_conf, **local_conf): def app_factory(global_conf, **local_conf):
conf = global_conf.copy()
conf.update(local_conf)
"""paste.deploy app factory for creating WSGI proxy apps.""" """paste.deploy app factory for creating WSGI proxy apps."""
return Application(local_conf) return Application(conf)