示例#1
0
def configure(server_config, **_):
    """ Configures the Tomcat server with a given server_config """
    ctx.logger.info('Configuring Tomcat server...')
    # Installs a custom setenv.sh with custom server jvm configuration
    if 'java_opts' in server_config:
        if server_config['java_opts'] is not None:
            java_opts = 'export JAVA_OPTS="' + server_config['java_opts'] + '"'
            ctx.logger.info('Custom JAVA_OPTS requested: ' + java_opts)
            set_env_sh = tempfile.mkstemp()
            set_env_sh_path = set_env_sh[1]
            ctx.logger.info(
                'Opening temp setenv.sh at {0}, writing: {1}'.format(
                    set_env_sh_path, java_opts))
            with open(set_env_sh_path, 'wb') as f:
                f.write(java_opts)
                f.flush()
                f.close()
            if 'catalina_home' not in server_config:
                raise exceptions.NonRecoverableError(
                    'Requested custom JAVA_OPTS but no "catalina_home" home specified!'
                )
            destination = server_config['catalina_home'] + 'bin/setenv.sh'
            ctx.logger.info(
                'Moving file to Catalina home: {0}'.format(destination))
            move_command = 'sudo mv ' + set_env_sh_path + ' ' + destination
            run(move_command)

    # Installs a user-defined server.xml and restarts the service
    if 'server_xml' in server_config:
        if server_config['server_xml'] is not None:
            server_xml_url = server_config['server_xml']
            ctx.logger.info('Custom server.xml requested: ' + server_xml_url)
            server_xml = tempfile.mkstemp()
            download_file(source=server_xml_url, destination=server_xml)
            server_xml_path = server_xml[1]
            if ctx.node.properties['tomcat_home_dir'] is None:
                raise exceptions.NonRecoverableError(
                    'Requested custom server.xml but no "tomcat_home_dir" specified!'
                )
            tomcat_home_dir = ctx.node.properties['tomcat_home_dir']
            ctx.logger.info('Moving file: ' + server_xml_url)
            move_command = 'sudo mv ' + server_xml_path + ' ' + tomcat_home_dir + '/server_xml'
            run(move_command)
示例#2
0
def configure(server_config, **_):
    """ Configures the Tomcat server with a given server_config """
    ctx.logger.info("Configuring Tomcat server...")
    # Installs a custom setenv.sh with custom server jvm configuration
    if "java_opts" in server_config:
        if server_config["java_opts"] is not None:
            java_opts = 'export JAVA_OPTS="' + server_config["java_opts"] + '"'
            ctx.logger.info("Custom JAVA_OPTS requested: " + java_opts)
            set_env_sh = tempfile.mkstemp()
            set_env_sh_path = set_env_sh[1]
            ctx.logger.info("Opening temp setenv.sh at {0}, writing: {1}".format(set_env_sh_path, java_opts))
            with open(set_env_sh_path, "wb") as f:
                f.write(java_opts)
                f.flush()
                f.close()
            if "catalina_home" not in server_config:
                raise exceptions.NonRecoverableError(
                    'Requested custom JAVA_OPTS but no "catalina_home" home specified!'
                )
            destination = server_config["catalina_home"] + "bin/setenv.sh"
            ctx.logger.info("Moving file to Catalina home: {0}".format(destination))
            move_command = "sudo mv " + set_env_sh_path + " " + destination
            run(move_command)

    # Installs a user-defined server.xml and restarts the service
    if "server_xml" in server_config:
        if server_config["server_xml"] is not None:
            server_xml_url = server_config["server_xml"]
            ctx.logger.info("Custom server.xml requested: " + server_xml_url)
            server_xml = tempfile.mkstemp()
            download_file(source=server_xml_url, destination=server_xml)
            server_xml_path = server_xml[1]
            if ctx.node.properties["tomcat_home_dir"] is None:
                raise exceptions.NonRecoverableError('Requested custom server.xml but no "tomcat_home_dir" specified!')
            tomcat_home_dir = ctx.node.properties["tomcat_home_dir"]
            ctx.logger.info("Moving file: " + server_xml_url)
            move_command = "sudo mv " + server_xml_path + " " + tomcat_home_dir + "/server_xml"
            run(move_command)
示例#3
0
def check_tomcat_health():
    run('curl localhost:8080')
示例#4
0
def check_tomcat_health():
    run("curl localhost:8080")