def set_up_m2ee_client(vcap_data): client = m2ee_class( yamlfiles=[".local/m2ee.yaml"], load_default_files=False, config={ "m2ee": { # this is named admin_pass, but it's the verification http header # to communicate with the internal management port of the runtime "admin_pass": security.get_m2ee_password() } }, ) version = client.config.get_runtime_version() mendix_runtimes_path = "/usr/local/share/mendix-runtimes.git" mendix_runtime_version_path = os.path.join(os.getcwd(), "runtimes", str(version)) if os.path.isdir(mendix_runtimes_path ) and not os.path.isdir(mendix_runtime_version_path): util.mkdir_p(mendix_runtime_version_path) env = dict(os.environ) env["GIT_WORK_TREE"] = mendix_runtime_version_path # checkout the runtime version process = subprocess.Popen( ["git", "checkout", str(version), "-f"], cwd=mendix_runtimes_path, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) process.communicate() if process.returncode != 0: logging.info("Mendix %s is not available in the rootfs", version) logging.info("Fallback (1): trying to fetch Mendix %s using git", version) process = subprocess.Popen( [ "git", "fetch", "origin", "refs/tags/{0}:refs/tags/{0}".format(str(version)), "&&", "git", "checkout", str(version), "-f", ], cwd=mendix_runtimes_path, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) process.communicate() if process.returncode != 0: logging.info( "Unable to fetch Mendix {} using git".format(version)) url = util.get_blobstore_url("/runtime/mendix-%s.tar.gz" % str(version)) logging.info( "Fallback (2): downloading Mendix {} from {}".format( version, url)) util.download_and_unpack(url, os.path.join(os.getcwd(), "runtimes")) client.reload_config() runtime.set_runtime_config( client.config._model_metadata, client.config._conf["mxruntime"], vcap_data, client, ) java_version = runtime.get_java_version( client.config.get_runtime_version())["version"] java.update_config(client.config._conf["m2ee"], vcap_data, java_version) runtime.set_jetty_config(client) newrelic.update_config(client, vcap_data["application_name"]) appdynamics.update_config(client, vcap_data["application_name"]) runtime.set_application_name(client, vcap_data["application_name"]) telegraf.update_config(client, vcap_data["application_name"]) datadog.update_config(client) return client
logging.warning( "CF_INSTANCE_INDEX environment variable not found. Assuming " "responsibility for scheduled events execution and database " "synchronization commands.") runtime.pre_process_m2ee_yaml() runtime.activate_license() m2ee = runtime.set_up_m2ee_client(util.get_vcap_data()) java_version = runtime.get_java_version( m2ee.config.get_runtime_version())["version"] java.update_config(m2ee.config._conf["m2ee"], util.get_vcap_data(), java_version) newrelic.update_config(m2ee, util.get_vcap_data()["application_name"]) appdynamics.update_config(m2ee, util.get_vcap_data()["application_name"]) dynatrace.update_config(m2ee, util.get_vcap_data()["application_name"]) mx_java_agent.update_config(m2ee) telegraf.update_config(m2ee, util.get_vcap_data()["application_name"]) ( databroker_jmx_instance_cfg, databroker_jmx_config_files, ) = databroker_processes.get_datadog_config( datadog._get_user_checks_dir()) datadog.update_config( m2ee, extra_jmx_instance_config=databroker_jmx_instance_cfg, jmx_config_files=databroker_jmx_config_files, ) @atexit.register