|
1
|
|
|
# Licensed to the StackStorm, Inc ('StackStorm') under one or more |
|
2
|
|
|
# contributor license agreements. See the NOTICE file distributed with |
|
3
|
|
|
# this work for additional information regarding copyright ownership. |
|
4
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0 |
|
5
|
|
|
# (the "License"); you may not use this file except in compliance with |
|
6
|
|
|
# the License. You may obtain a copy of the License at |
|
7
|
|
|
# |
|
8
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
|
9
|
|
|
# |
|
10
|
|
|
# Unless required by applicable law or agreed to in writing, software |
|
11
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
|
12
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13
|
|
|
# See the License for the specific language governing permissions and |
|
14
|
|
|
# limitations under the License. |
|
15
|
|
|
|
|
16
|
|
|
""" |
|
17
|
|
|
Configuration options registration and useful routines. |
|
18
|
|
|
""" |
|
19
|
|
|
|
|
20
|
|
|
import os |
|
21
|
|
|
|
|
22
|
|
|
from oslo_config import cfg |
|
23
|
|
|
|
|
24
|
|
|
import st2common.config as common_config |
|
25
|
|
|
from st2common.constants.system import VERSION_STRING |
|
26
|
|
|
|
|
27
|
|
|
CONF = cfg.CONF |
|
28
|
|
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
|
29
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
def parse_args(args=None): |
|
32
|
|
|
CONF(args=args, version=VERSION_STRING) |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
def register_opts(): |
|
36
|
|
|
_register_common_opts() |
|
37
|
|
|
_register_app_opts() |
|
38
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
def _register_common_opts(): |
|
41
|
|
|
common_config.register_opts() |
|
42
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
def get_logging_config_path(): |
|
45
|
|
|
return cfg.CONF.stream.logging |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
def _register_app_opts(): |
|
49
|
|
|
# Note "allow_origin", "mask_secrets" options are registered as part of st2common config since |
|
50
|
|
|
# they are also used outside st2stream |
|
51
|
|
|
api_opts = [ |
|
52
|
|
|
cfg.StrOpt('host', default='0.0.0.0', help='StackStorm stream API server host'), |
|
53
|
|
|
cfg.IntOpt('port', default=9102, help='StackStorm API stream, server port'), |
|
54
|
|
|
cfg.IntOpt('heartbeat', default=25, |
|
55
|
|
|
help='Send empty message every N seconds to keep connection open'), |
|
56
|
|
|
cfg.BoolOpt('debug', default=False, |
|
57
|
|
|
help='Specify to enable debug mode.'), |
|
58
|
|
|
cfg.StrOpt('logging', default='conf/logging.conf', |
|
59
|
|
|
help='location of the logging.conf file') |
|
60
|
|
|
] |
|
61
|
|
|
CONF.register_opts(api_opts, group='stream') |
|
62
|
|
|
|