Пример #1
0
def run(app_name, worker):
    parser = argparse.ArgumentParser(description="Admin Server Help")
    parser.add_argument(
        "-c", "--config", type=str, nargs="*", help="List of configuration files to import (python modules)"
    )
    parser.add_argument("-m", "--method", help="all, invoices or the like")
    parser.add_argument("action", choices=["start", "stop", "restart", "run"])
    cmd_args = parser.parse_args()

    config.configure(cmd_args.config or [])

    import logging_config

    logging_config.configure(app_name)

    daemon = worker(os.path.join(config.pid_dir, "{}.pid".format(app_name)))
    if cmd_args.action == "start":
        daemon.start()
    elif cmd_args.action == "stop":
        daemon.stop()
    elif cmd_args.action == "restart":
        daemon.restart()
    elif cmd_args.action == "run":
        if not cmd_args.method:
            daemon.run()
        else:
            attr = getattr(daemon, cmd_args.method, None)
            if attr is None:
                logger.critical("method unknown")
            else:
                attr()
                daemon.close()
Пример #2
0
"""
Copyright 2012 DISQUS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
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 logging_config
logging_config.configure()

import os

_basedir = os.path.abspath(os.path.dirname(__file__))

DEBUG = True
TESTING = True
SECRET_KEY = 'developement key'
ZK_CONNECTION_STRING = ''
ZK_DIGEST_PASSWORD = '******'

Пример #3
0
import logging_config
logging_config.configure('edi_ftp')
import config
import ftplib
import json
import cli
from utils.amqp import BlockingAMQP
from utils.export import OIOXML
from  pymongo import MongoClient
import logging
import daemon
logger = logging.getLogger(__name__)



class DS(daemon.Daemon):

    def run(self):
        logger.info('Starting DS amqp handler')
        self.oio = OIOXML()
        amqp = BlockingAMQP(on_message=self.on_message,
                host=config.amqp_host,
                user=config.amqp_user,
                password=config.amqp_password)
        try:
            amqp.start()
        except (KeyboardInterrupt, SystemExit) as ex:
            logger.exception(ex)
        except Exception as ex:
            logger.exception(ex)
            raise