| 749 | } |
| 750 | |
| 751 | int main(int argc, char **argv) |
| 752 | { |
| 753 | openlog("pmux", LOG_NDELAY | LOG_PERROR, LOG_USER); |
| 754 | |
| 755 | if (sizeof(event) < event_get_struct_event_size()) { |
| 756 | syslog(LOG_CRIT, "incorrect sizeof(event):%zu expected:%zu\n", |
| 757 | sizeof(event), event_get_struct_event_size()); |
| 758 | return EXIT_FAILURE; |
| 759 | } |
| 760 | |
| 761 | long open_max = sysconf(_SC_OPEN_MAX); |
| 762 | if (open_max == -1) { |
| 763 | syslog(LOG_WARNING, "sysconf(_SC_OPEN_MAX): %d %s ", errno, |
| 764 | strerror(errno)); |
| 765 | open_max = 20; |
| 766 | syslog(LOG_WARNING, "setting open_max to:%ld\n", open_max); |
| 767 | } |
| 768 | |
| 769 | std::string host; |
| 770 | char *hostptr = getenv("HOSTNAME"); |
| 771 | if (hostptr == nullptr) { |
| 772 | long hostname_max = sysconf(_SC_HOST_NAME_MAX); |
| 773 | if (hostname_max == -1) { |
| 774 | syslog(LOG_WARNING, "sysconf(_SC_HOST_NAME_MAX): %d %s ", errno, |
| 775 | strerror(errno)); |
| 776 | hostname_max = 255; |
| 777 | syslog(LOG_WARNING, "setting hostname_max to:%ld\n", hostname_max); |
| 778 | } |
| 779 | char myhost[hostname_max + 1]; |
| 780 | int rc = gethostname(myhost, hostname_max); |
| 781 | if (rc == 0) { |
| 782 | myhost[hostname_max] = '\0'; |
| 783 | host = hostptr = myhost; |
| 784 | } else { |
| 785 | syslog(LOG_CRIT, |
| 786 | "Can't figure out hostname: please export HOSTNAME.\n"); |
| 787 | return EXIT_FAILURE; |
| 788 | } |
| 789 | } else { |
| 790 | host = hostptr; |
| 791 | } |
| 792 | |
| 793 | bool foreground_mode = false; |
| 794 | std::string cluster("prod"); |
| 795 | std::string dbname("pmuxdb"); |
| 796 | std::vector<int> listen_ports; |
| 797 | enum store_mode { MODE_NONE, MODE_LOCAL, MODE_COMDB2 }; |
| 798 | store_mode store_mode = MODE_NONE; |
| 799 | std::pair<int, int> custom_range; |
| 800 | |
| 801 | int c; |
| 802 | while ((c = getopt(argc, argv, "hc:d:b:p:r:lnf")) != -1) { |
| 803 | switch (c) { |
| 804 | case 'h': |
| 805 | return usage(stdout, EXIT_SUCCESS); |
| 806 | break; |
| 807 | case 'c': |
| 808 | store_mode = MODE_COMDB2; |
nothing calls this directly
no test coverage detected