63 binary_name_ = std::string(basename(argv[0]));
66 if (process_group_.empty()) {
67 process_group_ = DEFAULT_process_group_;
70 if (sched_name_.empty()) {
71 sched_name_ = DEFAULT_sched_name_;
74 if (enable_cpuprofile_ && profile_filename_.empty()) {
76 profile_filename_ = pwd +
"/" + process_group_ + std::string(
"_cpu.prof");
79 if (profile_filename_[0] !=
'/') {
81 profile_filename_ = pwd +
"/" + profile_filename_;
84 if (enable_heapprofile_ && heapprofile_filename_.empty()) {
86 heapprofile_filename_ =
87 pwd +
"/" + process_group_ + std::string(
"_mem.prof");
90 if (heapprofile_filename_[0] !=
'/') {
92 heapprofile_filename_ = pwd +
"/" + heapprofile_filename_;
95 GlobalData::Instance()->SetProcessGroup(process_group_);
96 GlobalData::Instance()->SetSchedName(sched_name_);
97 AINFO <<
"binary_name_ is " << binary_name_ <<
", process_group_ is "
98 << process_group_ <<
", has " << dag_conf_list_.size() <<
" dag conf";
99 for (std::string& dag : dag_conf_list_) {
100 AINFO <<
"dag_conf: " << dag;
107 const std::string short_opts =
"hd:p:s:co:HO:";
108 static const struct option long_opts[] = {
109 {
"help", no_argument,
nullptr,
'h'},
110 {
"dag_conf", required_argument,
nullptr,
'd'},
111 {
"process_name", required_argument,
nullptr,
'p'},
112 {
"sched_name", required_argument,
nullptr,
's'},
113 {
"plugin", required_argument,
nullptr, ARGS_OPT_CODE_PLUGIN},
114 {
"disable_plugin_autoload", no_argument,
nullptr,
115 ARGS_OPT_CODE_DISABLE_PLUGIN_AUTOLOAD},
116 {
"cpuprofile", no_argument,
nullptr,
'c'},
117 {
"profile_filename", required_argument,
nullptr,
'o'},
118 {
"heapprofile", no_argument,
nullptr,
'H'},
119 {
"heapprofile_filename", required_argument,
nullptr,
'O'},
120 {NULL, no_argument,
nullptr, 0}};
124 for (
int i = 0; i < argc; ++i) {
128 AINFO <<
"command: " << cmd;
137 getopt_long(argc, argv, short_opts.c_str(), long_opts, &long_index);
143 dag_conf_list_.emplace_back(std::string(optarg));
144 for (
int i = optind; i < argc; i++) {
145 if (*argv[i] !=
'-') {
146 dag_conf_list_.emplace_back(std::string(argv[i]));
153 process_group_ = std::string(optarg);
156 sched_name_ = std::string(optarg);
158 case ARGS_OPT_CODE_PLUGIN:
159 plugin_description_list_.emplace_back(std::string(optarg));
161 case ARGS_OPT_CODE_DISABLE_PLUGIN_AUTOLOAD:
162 disable_plugin_autoload_ =
true;
165#ifndef BASE_PROFILER_H_
166 AWARN <<
"gperftools not installed, ignore perf parameters";
168 enable_cpuprofile_ =
true;
171 profile_filename_ = std::string(optarg);
174#ifndef BASE_PROFILER_H_
175 AWARN <<
"gperftools not installed, ignore perf parameters";
177 enable_heapprofile_ =
true;
180 heapprofile_filename_ = std::string(optarg);
191 AINFO <<
"Found non-option ARGV-element \"" << argv[optind++] <<
"\"";
196 if (dag_conf_list_.empty()) {
197 AINFO <<
"-d parameter must be specified";