61 binary_name_ = std::string(basename(argv[0]));
64 if (process_group_.empty()) {
65 process_group_ = DEFAULT_process_group_;
68 if (sched_name_.empty()) {
69 sched_name_ = DEFAULT_sched_name_;
72 if (enable_cpuprofile_ && profile_filename_.empty()) {
73 profile_filename_ = process_group_ + std::string(
"_cpu.prof");
76 if (enable_heapprofile_ && heapprofile_filename_.empty()) {
77 heapprofile_filename_ = process_group_ + std::string(
"_mem.prof");
80 GlobalData::Instance()->SetProcessGroup(process_group_);
81 GlobalData::Instance()->SetSchedName(sched_name_);
82 AINFO <<
"binary_name_ is " << binary_name_ <<
", process_group_ is "
83 << process_group_ <<
", has " << dag_conf_list_.size() <<
" dag conf";
84 for (std::string& dag : dag_conf_list_) {
85 AINFO <<
"dag_conf: " << dag;
92 const std::string short_opts =
"hd:p:s:co:HO:";
93 static const struct option long_opts[] = {
94 {
"help", no_argument,
nullptr,
'h'},
95 {
"dag_conf", required_argument,
nullptr,
'd'},
96 {
"process_name", required_argument,
nullptr,
'p'},
97 {
"sched_name", required_argument,
nullptr,
's'},
98 {
"plugin", required_argument,
nullptr, ARGS_OPT_CODE_PLUGIN},
99 {
"disable_plugin_autoload", no_argument,
nullptr,
100 ARGS_OPT_CODE_DISABLE_PLUGIN_AUTOLOAD},
101 {
"cpuprofile", no_argument,
nullptr,
'c'},
102 {
"profile_filename", required_argument,
nullptr,
'o'},
103 {
"heapprofile", no_argument,
nullptr,
'H'},
104 {
"heapprofile_filename", required_argument,
nullptr,
'O'},
105 {NULL, no_argument,
nullptr, 0}};
109 for (
int i = 0; i < argc; ++i) {
113 AINFO <<
"command: " << cmd;
122 getopt_long(argc, argv, short_opts.c_str(), long_opts, &long_index);
128 dag_conf_list_.emplace_back(std::string(optarg));
129 for (
int i = optind; i < argc; i++) {
130 if (*argv[i] !=
'-') {
131 dag_conf_list_.emplace_back(std::string(argv[i]));
138 process_group_ = std::string(optarg);
141 sched_name_ = std::string(optarg);
143 case ARGS_OPT_CODE_PLUGIN:
144 plugin_description_list_.emplace_back(std::string(optarg));
146 case ARGS_OPT_CODE_DISABLE_PLUGIN_AUTOLOAD:
147 disable_plugin_autoload_ =
true;
150#ifndef BASE_PROFILER_H_
151 AWARN <<
"gperftools not installed, ignore perf parameters";
153 enable_cpuprofile_ =
true;
156 profile_filename_ = std::string(optarg);
159#ifndef BASE_PROFILER_H_
160 AWARN <<
"gperftools not installed, ignore perf parameters";
162 enable_heapprofile_ =
true;
165 heapprofile_filename_ = std::string(optarg);
176 AINFO <<
"Found non-option ARGV-element \"" << argv[optind++] <<
"\"";
181 if (dag_conf_list_.empty()) {
182 AINFO <<
"-d parameter must be specified";