dolphin_logger_service.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 time
  17. from resource_management import *
  18. from dolphin_env import dolphin_env
  19. class DolphinLoggerService(Script):
  20. def install(self, env):
  21. import params
  22. env.set_params(params)
  23. self.install_packages(env)
  24. Execute(('chmod', '-R', '777', params.dolphin_home), user=params.dolphin_user, sudo=True)
  25. def configure(self, env):
  26. import params
  27. params.pika_slave = True
  28. env.set_params(params)
  29. dolphin_env()
  30. def start(self, env):
  31. import params
  32. env.set_params(params)
  33. self.configure(env)
  34. no_op_test = format("ls {dolphin_pidfile_dir}/logger-server.pid >/dev/null 2>&1 && ps `cat {dolphin_pidfile_dir}/logger-server.pid` | grep `cat {dolphin_pidfile_dir}/logger-server.pid` >/dev/null 2>&1")
  35. start_cmd = format("sh " + params.dolphin_bin_dir + "/dolphinscheduler-daemon.sh start logger-server")
  36. Execute(start_cmd, user=params.dolphin_user, not_if=no_op_test)
  37. def stop(self, env):
  38. import params
  39. env.set_params(params)
  40. stop_cmd = format("sh " + params.dolphin_bin_dir + "/dolphinscheduler-daemon.sh stop logger-server")
  41. Execute(stop_cmd, user=params.dolphin_user)
  42. time.sleep(5)
  43. def status(self, env):
  44. import status_params
  45. env.set_params(status_params)
  46. check_process_status(status_params.dolphin_run_dir + "logger-server.pid")
  47. if __name__ == "__main__":
  48. DolphinLoggerService().execute()