Ejemplo n.º 1
0
def service_validate_config(service):
    """
    Validate basic configuration options exist and are valid for the
    given service.
    """
    if not service_load_config(service):
        return 1

    # Package
    if not serviceconfig.package:
        print "You must specify a package to provide binaries"
        return 1
    package.package_load_config(serviceconfig.package)
    installdir = package.install_dir(serviceconfig.package)
    bindir = os.path.join(installdir, 'bin')
    if not os.path.exists(installdir) or not os.path.exists(bindir):
        print "Couldn't find installed binaries in package", serviceconfig.package
        return 1

    # Binary
    if not serviceconfig.binary:
        print "You must specify a binary to execute."
        return 1
    binfile = os.path.join(bindir, serviceconfig.binary)
    if not os.path.exists(binfile) or not os.path.isfile(binfile):
        print "Couldn't find binary file", serviceconfig.binary, "in package", serviceconfig.package
        return 1

    # Args - nothing to check, they can be omitted

    return True
Ejemplo n.º 2
0
def get_run_params(servname):
    class Params(object):
        pass

    # Load and validate config
    service_validate_config(servname)

    result = Params()

    result.name = servname
    result.work_dir = service_path(servname)
    result.pidfile = service_path(servname, 'pid')

    result.installdir = package.install_dir(serviceconfig.package)
    result.bindir = os.path.join(result.installdir, 'bin')
    result.binfile = os.path.join(result.bindir, serviceconfig.binary)

    return result