sharding_entry.cc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright [2021] JD.com, Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  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. */
  17. #include "sharding_entry.h"
  18. #include <unistd.h>
  19. #include "proc_title.h"
  20. const char *sharding_name = "sharding";
  21. ShardingEntry::ShardingEntry(WatchDog *watchdog, int sec)
  22. : WatchDogDaemon(watchdog, sec)
  23. {
  24. strncpy(watchdog_object_name_, "sharding", sizeof(watchdog_object_name_));
  25. }
  26. ShardingEntry::~ShardingEntry(void)
  27. {
  28. }
  29. void ShardingEntry::exec()
  30. {
  31. char *argv[4];
  32. int ret = system("./conf-gen-utils");
  33. if(ret == 0)
  34. {
  35. set_proc_title("agent_sharding");
  36. argv[0] = (char *)"../sharding/bin/start.sh";
  37. argv[1] = "3307";
  38. argv[2] = "../conf";
  39. argv[3] = NULL;
  40. execv(argv[0], argv);
  41. }
  42. }