|
@@ -35,6 +35,7 @@ from ambari_commons.constants import UPGRADE_TYPE_NON_ROLLING, UPGRADE_TYPE_ROLL
|
|
|
from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
|
|
|
from resource_management.libraries.resources import XmlConfig
|
|
|
from resource_management.libraries.resources import PropertiesFile
|
|
|
+from resource_management.core import sudo
|
|
|
from resource_management.core.resources import File, Directory
|
|
|
from resource_management.core.source import InlineTemplate
|
|
|
from resource_management.core.environment import Environment
|
|
@@ -255,6 +256,9 @@ class Script(object):
|
|
|
self.pre_start()
|
|
|
|
|
|
method(env)
|
|
|
+
|
|
|
+ if self.command_name == "start" and not self.is_hook():
|
|
|
+ self.post_start()
|
|
|
finally:
|
|
|
if self.should_expose_component_version(self.command_name):
|
|
|
self.save_component_version_to_structured_out()
|
|
@@ -268,6 +272,9 @@ class Script(object):
|
|
|
|
|
|
def get_user(self):
|
|
|
return ""
|
|
|
+
|
|
|
+ def get_pid_files(self):
|
|
|
+ return []
|
|
|
|
|
|
def pre_start(self):
|
|
|
if self.log_out_files:
|
|
@@ -275,15 +282,30 @@ class Script(object):
|
|
|
user = self.get_user()
|
|
|
|
|
|
if log_folder == "":
|
|
|
- Logger.logger.warn("Log folder for current script is not defined")
|
|
|
+ Logger.logger.error("Log folder for current script is not defined")
|
|
|
return
|
|
|
|
|
|
if user == "":
|
|
|
- Logger.logger.warn("User for current script is not defined")
|
|
|
+ Logger.logger.error("User for current script is not defined")
|
|
|
return
|
|
|
|
|
|
show_logs(log_folder, user, lines_count=COUNT_OF_LAST_LINES_OF_OUT_FILES_LOGGED, mask=OUT_FILES_MASK)
|
|
|
|
|
|
+ def post_start(self):
|
|
|
+ pid_files = self.get_pid_files()
|
|
|
+ if pid_files == []:
|
|
|
+ Logger.logger.error("Pid files for current script are not defined")
|
|
|
+ return
|
|
|
+
|
|
|
+ pids = []
|
|
|
+ for pid_file in pid_files:
|
|
|
+ if not sudo.path_exists(pid_file):
|
|
|
+ raise Fail("Pid file {0} doesn't exist after starting of the component.")
|
|
|
+
|
|
|
+ pids.append(sudo.read_file(pid_file).strip())
|
|
|
+
|
|
|
+ Logger.info("Component has started with pid(s): {0}".format(', '.join(pids)))
|
|
|
+
|
|
|
def choose_method_to_execute(self, command_name):
|
|
|
"""
|
|
|
Returns a callable object that should be executed for a given command.
|
|
@@ -689,6 +711,7 @@ class Script(object):
|
|
|
self.start(env, rolling_restart=(restart_type == "rolling_upgrade"))
|
|
|
else:
|
|
|
self.start(env)
|
|
|
+ self.post_start()
|
|
|
|
|
|
if is_stack_upgrade:
|
|
|
# Remain backward compatible with the rest of the services that haven't switched to using
|
|
@@ -809,4 +832,4 @@ class Script(object):
|
|
|
|
|
|
def __init__(self):
|
|
|
if Script.instance is not None:
|
|
|
- raise Fail("An instantiation already exists! Use, get_instance() method.")
|
|
|
+ raise Fail("An instantiation already exists! Use, get_instance() method.")
|