Support Cloudpulse with WSGI

Change-Id: Ibbe56daa10fa81559bd7b39104f58649be91d3c7
(cherry picked from commit fe39d727d8)
This commit is contained in:
Sawan Choudhary 2020-09-17 06:34:39 +00:00 committed by Anand Shanmugam
parent 9ec79f7de8
commit d4a1da3776
3 changed files with 25 additions and 0 deletions

5
cloudpulse.wsgi Executable file
View File

@ -0,0 +1,5 @@
# With wsgi the default config file will be read from
# /docker/cloudpulse/cloudpulse.conf
from pecan.deploy import deploy
application = deploy('/cloudpulse/cloudpulse/config.py')

View File

@ -9,12 +9,16 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import eventlet
eventlet.monkey_patch()
from oslo_config import cfg
import pecan
import sys
from cloudpulse.api import auth
from cloudpulse.api import config as api_config
from cloudpulse.api import hooks
from cloudpulse.api import middleware
from cloudpulse.common.timerthread import cpulseTimer
from cloudpulse.common.timerthread import timerfunc
@ -63,11 +67,24 @@ def get_pecan_config():
def setup_app(config=None):
# It is recomended to run cloudpulse with the config file
# However with wsgi the default config file will be read from
# /docker/cloudpulse/cloudpulse.conf
if len(sys.argv) == 1:
cfg.CONF(["--config-file", "/docker/cloudpulse/cloudpulse.conf"],
project='cloudpulse')
if not config:
config = get_pecan_config()
app_conf = dict(config.app)
app_conf["hooks"] = [
hooks.ContextHook(),
hooks.RPCHook(),
hooks.NoExceptionTracebackHook(),
]
app = pecan.make_app(
app_conf.pop('root'),
logging=getattr(config, 'logging', {}),

View File

@ -31,6 +31,9 @@ app = {
'static_root': '%(confdir)s/public',
'template_path': '%(confdir)s/api/templates',
'debug': True,
'acl_public_routes': [
'/'
],
'errors': {
404: '/error/404',
'__force_dict__': True