How to use the honcho.manager function in honcho

To help you get started, we’ve selected a few honcho examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github frascoweb / frasco / frasco / cli / run.py View on Github external
def start_honcho(processes, env=None):
    manager = honcho.manager.Manager()
    for p in honcho.environ.expand_processes(processes, env=env):
        e = os.environ.copy()
        e.update(p.env)
        manager.add_process(p.name, p.cmd, env=e)
    manager.loop()
    sys.exit(manager.returncode)
github oTree-org / otree-core / otree / management / commands / webandworkers.py View on Github external
naiveip_re = re.compile(r"""^(?:
(?P
    (?P\d{1,3}(?:\.\d{1,3}){3}) |         # IPv4 address
    (?P\[[a-fA-F0-9:]+\]) |               # IPv6 address
    (?P[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*) # FQDN
):)?(?P\d+)$""", re.X)

DEFAULT_PORT = "8000"
DEFAULT_ADDR = '0.0.0.0'
NUM_WORKERS = 3

# made this simple class to reduce code duplication,
# and to make testing easier (I didn't know how to check that it was called
# with os.environ.copy(), especially if we patch os.environ)
class OTreeHonchoManager(honcho.manager.Manager):
    def add_otree_process(self, name, cmd):
        self.add_process(name, cmd, env=os.environ.copy(), quiet=False)

def twisted_ssl_file_path(filename):
    otree_dir = os.path.dirname(otree.__file__)
    pth = os.path.join(otree_dir, 'certs', filename)
    return pth.replace('\\', '/').replace(':', '\\:')

class Command(BaseCommand):
    help = 'Run otree web services for the production environment.'

    def add_arguments(self, parser):
        BaseCommand.add_arguments(self, parser)

        parser.add_argument('addrport', nargs='?',
            help='Optional port number, or ipaddr:port')
github oTree-org / otree-core / otree / management / commands / runprodserver1of2.py View on Github external
# hypercorn/uvicorn don't support multiple workers on windows.
# daphne doesn't support multiple workers at all.
# https://github.com/django/channels/issues/960
# https://gitlab.com/pgjones/hypercorn/issues/84
# https://github.com/encode/uvicorn/issues/342#issuecomment-480230739
if sys.platform.startswith("win"):
    NUM_WORKERS = 1
else:
    NUM_WORKERS = 3


# made this simple class to reduce code duplication,
# and to make testing easier (I didn't know how to check that it was called
# with os.environ.copy(), especially if we patch os.environ)
class OTreeHonchoManager(honcho.manager.Manager):
    def add_otree_process(self, name, cmd):
        self.add_process(name, cmd, env=os.environ.copy(), quiet=False)


class Command(BaseCommand):
    help = 'oTree production server.'

    def add_arguments(self, parser):

        parser.add_argument(
            'addrport', nargs='?', help='Optional port number, or ipaddr:port'
        )

    def handle(self, *args, addrport=None, verbosity=1, **kwargs):
        self.verbosity = verbosity
        os.environ['OTREE_USE_REDIS'] = '1'
github deeplearninc / relaax / relaax / cmdl / commands / cmd_run.py View on Github external
wsproxy          - run websockets proxy

    \b
    For example:
        - run environment, rlx-server, parameter-server, metrics-server, and wsproxy
        $relaax run all
        - run rlx-server, parameter-server, metrics-server, and wsproxy
        $relaax run servers
    """
    ctx.setup_logger(format='%(asctime)s %(name)s\t\t  | %(message)s')
    # Disable TF warnings
    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
    os.environ["COMSPEC"]= "powershell.exe"
    # Execute command
    if sys.platform == 'win32':
        honcho.manager.KILL_WAIT = 120
        honcho.process.Popen = PopenPatched
    
        import _winapi, ctypes
        
        firstRun = False 
        mutex = ctypes.windll.kernel32.CreateMutexA(None, False, "RELAAX_WINDOWS_MUTEX")
        if _winapi.GetLastError() == 0:
            firstRun1 = True
            
        if firstRun:
            os.system("start powershell " + ' '.join(sys.argv))
            time.sleep(5)
            _winapi.CloseHandle(mutex)
        else:
            _winapi.CloseHandle(mutex)    
            honcho.process.Popen = PopenPatched