wcs.manageconfigfile.diff
wcs.cfg-sample | ||
---|---|---|
1 |
[main] |
|
2 |
app_dir = /var/lib/wcs |
|
3 |
data_dir = /usr/share/wcs |
|
4 |
auto_create_vhosts = true |
|
5 |
use_long_traces = true |
|
6 |
#error_log = /var/log/wcs/error.log |
|
7 |
#redirect_on_unknown_vhost = http://www.mysite.com |
wcs/ctl/apply_timeouts.py | ||
---|---|---|
21 | 21 |
class CmdApplyTimeouts(Command): |
22 | 22 |
name = 'apply_timeouts' |
23 | 23 | |
24 |
def __init__(self): |
|
25 |
Command.__init__(self, [ |
|
24 |
def __init__(self, main_options):
|
|
25 |
Command.__init__(self, main_options, [
|
|
26 | 26 |
make_option('--extra', metavar='DIR', action='append', |
27 | 27 |
dest='extra', default=[]), |
28 | 28 |
make_option('--app-dir', metavar='DIR', action='store', |
... | ... | |
37 | 37 |
import wcs.workflows as workflows |
38 | 38 |
import publisher |
39 | 39 | |
40 |
if options.app_dir: |
|
41 |
publisher.WcsPublisher.APP_DIR = options.app_dir |
|
42 |
if options.data_dir: |
|
43 |
publisher.WcsPublisher.DATA_DIR = options.data_dir |
|
40 |
self.configure_publisher(publisher.WcsPublisher, options) |
|
44 | 41 |
if options.silent: |
45 | 42 |
sys.stdout = file('/dev/null', 'w') |
46 | 43 |
sys.stderr = file('/dev/null', 'w') |
wcs/ctl/clean_sessions.py | ||
---|---|---|
43 | 43 |
def execute(self, options, args): |
44 | 44 |
import publisher |
45 | 45 | |
46 |
self.configure_publisher(publisher.WcsPublisher, options) |
|
46 | 47 |
pub = publisher.WcsPublisher.create_publisher() |
47 | 48 | |
48 | 49 |
app_dir = pub.app_dir |
wcs/ctl/export_settings.py | ||
---|---|---|
24 | 24 |
class CmdExportSettings(Command): |
25 | 25 |
name = 'export_settings' |
26 | 26 | |
27 |
def __init__(self): |
|
28 |
Command.__init__(self, [ |
|
29 |
make_option('--vhost', metavar='VHOST', action='store', |
|
30 |
dest='vhost'), |
|
27 |
def __init__(self, main_options): |
|
28 |
Command.__init__(self, main_options, |
|
29 |
[ |
|
30 |
make_option('--extra', metavar='DIR', action='append', |
|
31 |
dest='extra', default=[]), |
|
32 |
make_option('--app-dir', metavar='DIR', action='store', |
|
33 |
dest='app_dir', default=None), |
|
34 |
make_option('--data-dir', metavar='DIR', action='store', |
|
35 |
dest='data_dir', default=None), |
|
36 |
make_option('--vhost', metavar='VHOST', action='store', |
|
37 |
dest='vhost'), |
|
31 | 38 |
]) |
32 | 39 | |
33 | 40 |
def execute(self, options, args): |
34 | 41 |
import publisher |
35 | 42 |
stdout = sys.stdout |
43 |
self.configure_publisher(publisher.WcsPublisher, options) |
|
36 | 44 |
pub = publisher.WcsPublisher.create_publisher() |
37 | 45 |
pub.app_dir = os.path.join(pub.app_dir, options.vhost) |
38 | 46 |
pub.reload_cfg() |
wcs/ctl/process_bounce.py | ||
---|---|---|
59 | 59 |
except (IndexError, KeyError): |
60 | 60 |
return |
61 | 61 | |
62 |
self.configure_publisher(publisher.WcsPublisher, options) |
|
62 | 63 |
pub = publisher.WcsPublisher.create_publisher() |
63 | 64 |
pub.app_dir = os.path.join(pub.app_dir, server_part) |
64 | 65 |
wcs/ctl/rebuild_indexes.py | ||
---|---|---|
36 | 36 |
class CmdRebuildIndexes(Command): |
37 | 37 |
name = 'rebuild_indexes' |
38 | 38 | |
39 |
def __init__(self): |
|
40 |
Command.__init__(self, [ |
|
39 |
def __init__(self, main_options):
|
|
40 |
Command.__init__(self, main_options, [
|
|
41 | 41 |
make_option('--all', action='store_true', |
42 |
dest='all', default=False),
|
|
42 |
dest='all', default=False), |
|
43 | 43 |
make_option('--destroy', action='store_true', |
44 |
dest='destroy', default=False),
|
|
44 |
dest='destroy', default=False), |
|
45 | 45 |
make_option('--extra', metavar='DIR', action='append', |
46 |
dest='extra', default=[]), |
|
46 |
dest='extra', default=[]), |
|
47 |
make_option('--app-dir', metavar='DIR', action='store', |
|
48 |
dest='app_dir', default=None), |
|
49 |
make_option('--data-dir', metavar='DIR', action='store', |
|
50 |
dest='data_dir', default=None), |
|
47 | 51 |
]) |
48 | 52 | |
49 | 53 |
def execute(self, options, args): |
50 | 54 |
import publisher |
51 | 55 | |
52 |
for directory in options.extra: |
|
53 |
publisher.WcsPublisher.register_extra_dir(directory) |
|
54 | ||
56 |
self.configure_publisher(publisher.WcsPublisher, options) |
|
55 | 57 |
pub = publisher.WcsPublisher.create_publisher() |
56 | 58 | |
57 | 59 |
app_dir = pub.app_dir |
wcs/ctl/start.py | ||
---|---|---|
26 | 26 |
class CmdStart(Command): |
27 | 27 |
name = 'start' |
28 | 28 | |
29 |
def __init__(self): |
|
30 |
Command.__init__(self, [ |
|
29 |
def __init__(self, main_options):
|
|
30 |
Command.__init__(self, main_options, [
|
|
31 | 31 |
make_option('--port', metavar='PORT', action='store', |
32 | 32 |
dest='port', default=3001), |
33 | 33 |
make_option('--extra', metavar='DIR', action='append', |
... | ... | |
44 | 44 |
make_option('--http', action='store_true', |
45 | 45 |
dest='http', default=False), |
46 | 46 |
make_option('--silent', action='store_true', |
47 |
dest='silent', default=False),
|
|
47 |
dest='silent', default=False), |
|
48 | 48 |
]) |
49 | 49 | |
50 | 50 |
def execute(self, options, args): |
... | ... | |
54 | 54 |
run_kwargs['port'] = int(options.port) |
55 | 55 |
run_kwargs['spawn_cron'] = True |
56 | 56 |
run_function = qommon.scgi_server.run |
57 |
for directory in options.extra: |
|
58 |
publisher.WcsPublisher.register_extra_dir(directory) |
|
57 |
self.configure_publisher(publisher.WcsPublisher, options) |
|
59 | 58 |
if options.handler_connection_limit: |
60 | 59 |
run_kwargs['handler_connection_limit'] = int(options.handler_connection_limit) |
61 | 60 |
if options.script_name: |
62 | 61 |
run_kwargs['script_name'] = options.script_name |
63 |
if options.app_dir: |
|
64 |
publisher.WcsPublisher.APP_DIR = options.app_dir |
|
65 |
if options.data_dir: |
|
66 |
publisher.WcsPublisher.DATA_DIR = options.data_dir |
|
67 | 62 |
if options.http: |
68 | 63 |
run_function = qommon.scgi_server.http_run |
69 | 64 |
if options.silent: |
wcs/qommon/cron.py | ||
---|---|---|
80 | 80 |
global cron_pid |
81 | 81 |
cron_pid = os.fork() |
82 | 82 |
if cron_pid == 0: |
83 |
print >>sys.stderr, 'Cron process launched' |
|
84 | 83 |
pub = create_publisher() |
85 | 84 |
# set process name, this only works on Linux, 15 == PR_SET_NAME |
86 | 85 |
if dl: |
wcs/qommon/ctl.py | ||
---|---|---|
16 | 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
17 | 17 |
# 02110-1301 USA |
18 | 18 | |
19 |
import ConfigParser |
|
19 | 20 |
import optparse |
20 | 21 |
from optparse import make_option |
21 | 22 |
import sys |
... | ... | |
34 | 35 |
name = None |
35 | 36 |
usage_args = '[ options ... ]' |
36 | 37 | |
37 |
def __init__(self, options=[]): |
|
38 |
self.options = options |
|
38 |
def __init__(self, main_options, options=None): |
|
39 |
if options: |
|
40 |
self.options = options |
|
41 |
else: |
|
42 |
self.options = [ |
|
43 |
make_option('--extra', metavar='DIR', action='append', |
|
44 |
dest='extra', default=[]), |
|
45 |
make_option('--app-dir', metavar='DIR', action='store', |
|
46 |
dest='app_dir', default=None), |
|
47 |
make_option('--data-dir', metavar='DIR', action='store', |
|
48 |
dest='data_dir', default=None), |
|
49 |
] |
|
50 |
self.config = ConfigParser.ConfigParser() |
|
51 |
if main_options.configfile: |
|
52 |
try: |
|
53 |
self.config.read(main_options.configfile) |
|
54 |
except ConfigParser.ParsingError, e: |
|
55 |
print >> sys.stderr, 'Invalid configuration file %s' % main_options.configfile |
|
56 |
print >> sys.stderr, e |
|
57 |
print >> sys.stderr, 'Using default options' |
|
58 |
if not self.config.has_section('main'): |
|
59 |
self.config.add_section('main') |
|
39 | 60 | |
40 | 61 |
def run(self, args): |
41 | 62 |
options, args = self.parse_args(args) |
42 | 63 |
return self.execute(options, args) |
43 | 64 | |
65 |
def configure_publisher(self, publisher_cls, options): |
|
66 |
for directory in options.extra: |
|
67 |
publisher_cls.register_extra_dir(directory) |
|
68 |
if options.app_dir: |
|
69 |
publisher_cls.APP_DIR = options.app_dir |
|
70 |
elif self.config.has_option("main", "app_dir"): |
|
71 |
publisher_cls.APP_DIR = self.config.get("main", "app_dir") |
|
72 |
if options.data_dir: |
|
73 |
publisher_cls.DATA_DIR = options.data_dir |
|
74 |
elif self.config.has_option("main", "data_dir"): |
|
75 |
publisher_cls.DATA_DIR = self.config.get("main", "data_dir") |
|
76 |
if self.config.has_option("main", "error_log"): |
|
77 |
publisher_cls.ERROR_LOG = self.config.get("main", "error_log") |
|
78 |
if self.config.has_option("main", "use_long_traces"): |
|
79 |
publisher_cls.auto_create_appdir = self.config.getboolean("main", "use_long_traces") |
|
80 |
if self.config.has_option("main", "auto_create_vhosts"): |
|
81 |
publisher_cls.auto_create_appdir = self.config.getboolean("main", "auto_create_vhosts") |
|
82 |
if self.config.has_option("main", "redirect_on_unknown_vhost"): |
|
83 |
publisher_cls.missing_appdir_redirect = self.config.get("main", "redirect_on_unknown_vhost") |
|
84 | ||
44 | 85 |
def parse_args(self, args): |
45 | 86 |
self.parser = optparse.OptionParser( |
46 | 87 |
usage='%%prog %s %s' % (self.name, _(self.usage_args)), |
... | ... | |
111 | 152 |
except ImportError: |
112 | 153 |
pass |
113 | 154 |
command_class = qommon._commands[command] |
114 |
cmd = command_class() |
|
155 |
cmd = command_class(options)
|
|
115 | 156 |
return cmd.run(args) |
116 | 157 |