logfeeder.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. """
  2. Licensed to the Apache Software Foundation (ASF) under one
  3. or more contributor license agreements. See the NOTICE file
  4. distributed with this work for additional information
  5. regarding copyright ownership. The ASF licenses this file
  6. to you under the Apache License, Version 2.0 (the
  7. "License"); you may not use this file except in compliance
  8. with the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. """
  16. import getpass
  17. from resource_management.core.resources.system import Execute
  18. from resource_management.libraries.functions.format import format
  19. from resource_management.libraries.functions.check_process_status import check_process_status
  20. from resource_management.libraries.script.script import Script
  21. from setup_logfeeder import setup_logfeeder
  22. from logsearch_common import kill_process
  23. class LogFeeder(Script):
  24. def install(self, env):
  25. import params
  26. env.set_params(params)
  27. self.install_packages(env)
  28. def configure(self, env, upgrade_type=None):
  29. import params
  30. env.set_params(params)
  31. setup_logfeeder()
  32. def start(self, env, upgrade_type=None):
  33. import params
  34. env.set_params(params)
  35. self.configure(env)
  36. Execute((format('{logfeeder_dir}/run.sh'),),
  37. environment={'LOGFEEDER_INCLUDE': format('{logsearch_logfeeder_conf}/logfeeder-env.sh')},
  38. sudo=True)
  39. def stop(self, env, upgrade_type=None):
  40. import params
  41. env.set_params(params)
  42. kill_process(params.logfeeder_pid_file, getpass.getuser(), params.logfeeder_log_dir)
  43. def status(self, env):
  44. import status_params
  45. env.set_params(status_params)
  46. check_process_status(status_params.logfeeder_pid_file)
  47. if __name__ == "__main__":
  48. LogFeeder().execute()