コード例 #1
0
ファイル: service.py プロジェクト: TeraprocSoftware/jaguar
def start(config, daemon):
    """Start Jaguar service.

    Examples:

    $ jaguar service start

    $ jaguar service --daemon start
    """
    # Make sure java is available
    if not environ.get(JAGUAR_HOME):
        raise click.UsageError('JAGUAR_HOME envrionment variable is not set.')
    dir_must_exist(environ.get(JAGUAR_HOME))
    execute_envsh(config.conf)
    if environ["JAVA_HOME"] is not None and environ["JAVA_HOME"]:
        prg = join(environ["JAVA_HOME"], "bin", "java")
    else:
        prg = which("java")

    if prg is None:
        quit("Cannot locate java.")
    # Jaguar conf
    properties = join(config.conf, JAGUAR_PROPERTIES)
    args = JAGUAR_CONF_ARGS.format(properties).split()
    # Jaguar log
    logback = join(config.conf, JAGUAR_LOGBACK)
    args.extend(JAGUAR_LOG_ARGS.format(logback).split())
    # Jaguar port
    args.extend(JAGUAR_PORT_ARGS.format(config.server['port']).split())
    # Jaguar classpath
    classpath = join(environ.get(JAGUAR_HOME), 'lib', '*')
    jvm_opts_list = DEFAULT_JVM_OPTS.split()
    # Shall we daemonize?
    if daemon:
        daemonize()
        environ['LOG_APPENDER'] = 'FILE'
    else:
        environ['LOG_APPENDER'] = 'STDOUT'

    commandline = [prg]
    commandline.extend(jvm_opts_list)
    commandline.append("-classpath")
    commandline.append(classpath)
    commandline.append(JAGUAR_CLASSNAME)
    commandline.extend(args)

    return run(commandline)
コード例 #2
0
ファイル: jaguar.py プロジェクト: TeraprocSoftware/jaguar
def jaguar(ctx, server, conf, verbose):
    """The Jaguar CLI"""
    conf = dir_must_exist(parse_conf_dir(conf))
    user = getuser()
    ctx.obj = Config(server, conf, user, verbose)