static void show_help(const char *cmd) { fprintf(stdout, "Use: %s [options] <command> <xsize> <ysize>\n", cmd); fprintf(stdout, "where options are:\n"); fprintf(stdout, " %-30s Show this help screen\n", "-h,--help"); fprintf(stdout, " %-30s Show version string\n", "-v,--version"); fprintf(stdout, " %-30s Enable debugging for this subsystem. (Try -d all to start.)\n", "-d,--debug=<subsystem>"); fprintf(stdout, " %-30s Automatically choose between multicore and batch mode.\n", "-A,--auto"); fprintf(stdout, " %-30s Save progress image to this file.\n", "-i,--bitmap=<file.bmp>"); fprintf(stdout, " %-30s Save progress log to this file.\n", "-l,--log-file=<file>"); fprintf(stdout, " %-30s Manually set the block size for batch mode.\n", "-b,--block-size=<size>"); fprintf(stdout, " %-30s Run the whole problem locally in multicore mode. (default)\n", "-L,--multicore"); fprintf(stdout, " %-30s Manually set the number of process to run at once.\n", "-n,--jobs=<njobs>"); fprintf(stdout, " %-30s Send debugging to this file. (can also be :stderr, :stdout, :syslog, or :journal)\n", "-o,--debug-file=<file>"); fprintf(stdout, " %-30s Interval between image writes, in seconds. (default=%d)\n", "-t,--bitmap-interval=<secs>",progress_bitmap_interval); fprintf(stdout, " %-30s Run in distributed mode with <type> batch system: (default=%s)\n", "-T,--batch-type=<type>", batch_queue_type_to_string(batch_system_type)); fprintf(stdout, " %-30s %s\n", "", batch_queue_type_string()); fprintf(stdout, " %-30s Verify mode: check the configuration and then exit.\n", "-V,--verify"); }
static void show_help(const char *cmd) { printf("Use: %s [options] <command> <xsize> <ysize>\n", cmd); printf("where options are:\n"); printf(" -n <njobs> Manually set the number of process to run at once.\n"); printf(" -b <size> Manually set the block size for batch mode.\n"); printf(" -d <subsystem> Enable debugging for this subsystem. (Try -d all to start.)\n"); printf(" -o <file> Send debugging to this file.\n"); printf(" -l <file> Save progress log to this file.\n"); printf(" -i <file.bmp> Save progress image to this file.\n"); printf(" -t <secs> Interval between image writes, in seconds. (default=%d)\n",progress_bitmap_interval); printf(" -A Automatically choose between multicore and batch mode.\n"); printf(" -M Run the whole problem locally in multicore mode. (default)\n"); printf(" -D Run the whole problem in distributed mode.\n"); printf(" -T <type> Type of batch system: %s\n",batch_queue_type_string()); printf(" -V Verify mode: check the configuration and then exit.\n"); printf(" -v Show version string\n"); printf(" -h Show this help screen\n"); }
int main(int argc, char *argv[]) { batch_queue_type_t batch_queue_type = BATCH_QUEUE_TYPE_UNKNOWN; catalog_host = CATALOG_HOST; catalog_port = CATALOG_PORT; batch_submit_options = getenv("BATCH_OPTIONS"); debug_config(argv[0]); resources = rmsummary_create(-1); int c; while((c = getopt_long(argc, argv, "B:C:F:N:M:T:t:w:W:E:P:S:cd:o:O:vh", long_options, NULL)) > -1) { switch (c) { case 'B': batch_submit_options = xxstrdup(optarg); break; case 'C': config_file = xxstrdup(optarg); break; case 'F': foremen_regex = xxstrdup(optarg); break; case 'N': case 'M': project_regex = xxstrdup(optarg); break; case 'T': batch_queue_type = batch_queue_type_from_string(optarg); if(batch_queue_type == BATCH_QUEUE_TYPE_UNKNOWN) { fprintf(stderr, "unknown batch queue type: %s\n", optarg); return EXIT_FAILURE; } break; case 't': worker_timeout = atoi(optarg); break; case 'w': workers_min = atoi(optarg); break; case 'W': workers_max = atoi(optarg); break; case LONG_OPT_WORKERS_PER_CYCLE: workers_per_cycle = atoi(optarg); break; case LONG_OPT_TASKS_PER_WORKER: tasks_per_worker = atof(optarg); break; case 'E': extra_worker_args = xxstrdup(optarg); break; case LONG_OPT_CORES: resources->cores = atoi(optarg); break; case LONG_OPT_AMAZON_CREDENTIALS: amazon_credentials = xxstrdup(optarg); break; case LONG_OPT_AMAZON_AMI: amazon_ami = xxstrdup(optarg); break; case LONG_OPT_MEMORY: resources->memory = atoi(optarg); break; case LONG_OPT_DISK: resources->disk = atoi(optarg); break; case LONG_OPT_GPUS: resources->gpus = atoi(optarg); break; case LONG_OPT_AUTOSIZE: autosize = 1; break; case LONG_OPT_FACTORY_TIMEOUT: factory_timeout = MAX(0, atoi(optarg)); break; case LONG_OPT_CONDOR_REQUIREMENTS: if(condor_requirements) { char *tmp = condor_requirements; condor_requirements = string_format("(%s && (%s))", tmp, optarg); free(tmp); } else { condor_requirements = string_format("(%s)", optarg); } break; case LONG_OPT_WRAPPER: wrapper_command = optarg; break; case LONG_OPT_WRAPPER_INPUT: if(!wrapper_input) { wrapper_input = strdup(optarg); } else { wrapper_input = string_format("%s,%s",wrapper_input,optarg); } break; case 'P': password_file = optarg; break; case 'S': scratch_dir = optarg; break; case 'c': consider_capacity = 1; break; case 'd': debug_flags_set(optarg); break; case 'o': debug_config_file(optarg); break; case 'O': debug_config_file_size(string_metric_parse(optarg)); break; case 'v': cctools_version_print(stdout, argv[0]); exit(EXIT_SUCCESS); case 'h': show_help(argv[0]); exit(EXIT_SUCCESS); default: show_help(argv[0]); return EXIT_FAILURE; } } if(project_regex) { using_catalog = 1; } else if((argc - optind) == 2) { master_host = argv[optind]; master_port = atoi(argv[optind+1]); } else { fprintf(stderr,"work_queue_factory: You must either give a project name with the -M option or master-name option with a configuration file, or give the master's host and port.\n"); show_help(argv[0]); exit(1); } cctools_version_debug(D_DEBUG, argv[0]); if(batch_queue_type == BATCH_QUEUE_TYPE_UNKNOWN) { fprintf(stderr,"work_queue_factory: You must specify a batch type with the -T option.\n"); fprintf(stderr, "valid options:\n"); fprintf(stderr, "%s\n", batch_queue_type_string()); return 1; } if(config_file) { char abs_path_name[PATH_MAX]; if(!realpath(config_file, abs_path_name)) { fprintf(stderr, "work_queue_factory: could not resolve configuration file path: '%s'.\n", config_file); exit(EXIT_FAILURE); } free(config_file); /* From now on, read config_file from absolute path */ config_file = xxstrdup(abs_path_name); if(!read_config_file(config_file)) { fprintf(stderr,"work_queue_factory: There were errors in the configuration file: %s\n", config_file); return 1; } } if(workers_min>workers_max) { fprintf(stderr,"work_queue_factory: min workers (%d) is greater than max workers (%d)\n",workers_min, workers_max); return 1; } /* Careful here: most of the supported batch systems expect that jobs are submitting from a single shared filesystem. Changing to /tmp only works in the case of Condor. */ if(!scratch_dir) { if(batch_queue_type==BATCH_QUEUE_TYPE_CONDOR) { scratch_dir = string_format("/tmp/wq-pool-%d",getuid()); } else { scratch_dir = string_format("wq-pool-%d",getuid()); } } if(!create_dir(scratch_dir,0777)) { fprintf(stderr,"work_queue_factory: couldn't create %s: %s",scratch_dir,strerror(errno)); return 1; } char cmd[1024]; sprintf(cmd,"cp \"$(which work_queue_worker)\" '%s'",scratch_dir); if (system(cmd)) { fprintf(stderr, "work_queue_factory: please add work_queue_worker to your PATH.\n"); exit(EXIT_FAILURE); } if(password_file) { sprintf(cmd,"cp %s %s/pwfile",password_file,scratch_dir); system(cmd); } if(chdir(scratch_dir)!=0) { fprintf(stderr,"work_queue_factory: couldn't chdir to %s: %s",scratch_dir,strerror(errno)); return 1; } signal(SIGINT, handle_abort); signal(SIGQUIT, handle_abort); signal(SIGTERM, handle_abort); signal(SIGHUP, ignore_signal); queue = batch_queue_create(batch_queue_type); if(!queue) { fprintf(stderr,"work_queue_factory: couldn't establish queue type %s",batch_queue_type_to_string(batch_queue_type)); return 1; } batch_queue_set_option(queue, "batch-options", batch_submit_options); batch_queue_set_option(queue, "autosize", autosize ? "yes" : NULL); set_worker_resources_options( queue ); if (amazon_credentials != NULL) { batch_queue_set_option(queue, "amazon-credentials", amazon_credentials); } if (amazon_ami != NULL) { batch_queue_set_option(queue, "amazon-ami", amazon_ami); } if(condor_requirements != NULL && batch_queue_type != BATCH_QUEUE_TYPE_CONDOR) { debug(D_NOTICE, "condor_requirements will be ignored as workers will not be running in condor."); } else { batch_queue_set_option(queue, "condor-requirements", condor_requirements); } mainloop( queue ); batch_queue_delete(queue); return 0; }
static void show_help(const char *cmd) { printf("Use: work_queue_factory [options] <masterhost> <port>\nor\n work_queue_factory [options] -M projectname\n"); printf("where options are:\n"); printf(" %-30s Project name of masters to serve, can be a regular expression.\n", "-M,-N,--master-name=<project>");\ printf(" %-30s Foremen to serve, can be a regular expression.\n", "-F,--foremen-name=<project>"); printf(" %-30s Batch system type (required). One of: %s\n", "-T,--batch-type=<type>",batch_queue_type_string()); printf(" %-30s Add these options to all batch submit files.\n", "-B,--batch-options=<options>"); printf(" %-30s Password file for workers to authenticate to master.\n","-P,--password"); printf(" %-30s Use configuration file <file>.\n","-C,--config-file=<file>"); printf(" %-30s Minimum workers running. (default=%d)\n", "-w,--min-workers", workers_min); printf(" %-30s Maximum workers running. (default=%d)\n", "-W,--max-workers", workers_max); printf(" %-30s Maximum number of new workers per %d s. (less than 1 disables limit, default=%d)\n", "--workers-per-cycle", factory_period, workers_per_cycle); printf(" %-30s Average tasks per worker. (default=one task per core)\n", "--tasks-per-worker"); printf(" %-30s Workers abort after this amount of idle time. (default=%d)\n", "-t,--timeout=<time>",worker_timeout); printf(" %-30s Extra options that should be added to the worker.\n", "-E,--extra-options=<options>"); printf(" %-30s Set the number of cores requested per worker.\n", "--cores=<n>"); printf(" %-30s Set the number of GPUs requested per worker.\n", "--gpus=<n>"); printf(" %-30s Set the amount of memory (in MB) requested per worker.\n", "--memory=<mb> "); printf(" %-30s Set the amount of disk (in MB) requested per worker.\n", "--disk=<mb>"); printf(" %-30s Automatically size a worker to an available slot (Condor only).\n", "--autosize"); printf(" %-30s Manually set requirements for the workers as condor jobs. May be specified several times, with the expresions and-ed together (Condor only).\n", "--condor-requirements"); printf(" %-30s Exit after no master has been seen in <n> seconds.\n", "--factory-timeout"); printf(" %-30s Use this scratch dir for temporary files. (default is /tmp/wq-pool-$uid)\n","-S,--scratch-dir"); printf(" %-30s Use worker capacity reported by masters.\n","-c,--capacity"); printf(" %-30s Enable debugging for this subsystem.\n", "-d,--debug=<subsystem>"); printf(" %-30s Specify path to Amazon credentials (for use with -T amazon)\n", "--amazon-credentials"); printf(" %-30s Specify amazon machine image (AMI). (for use with -T amazon)\n", "--amazon-ami"); printf(" %-30s Wrap factory with this command prefix.\n","--wrapper"); printf(" %-30s Add this input file needed by the wrapper.\n","--wrapper-input"); printf(" %-30s Send debugging to this file. (can also be :stderr, :stdout, :syslog, or :journal)\n", "-o,--debug-file=<file>"); printf(" %-30s Show this screen.\n", "-h,--help"); }
int main(int argc, char *argv[]) { batch_queue_type_t batch_queue_type = BATCH_QUEUE_TYPE_UNKNOWN; catalog_host = CATALOG_HOST; catalog_port = CATALOG_PORT; debug_config(argv[0]); int c; while((c = getopt_long(argc, argv, "F:N:M:T:t:w:W:E:P:S:cd:o:O:vh", long_options, NULL)) > -1) { switch (c) { case 'F': foremen_regex = optarg; break; case 'N': case 'M': project_regex = optarg; break; case 'T': batch_queue_type = batch_queue_type_from_string(optarg); if(batch_queue_type == BATCH_QUEUE_TYPE_UNKNOWN) { fprintf(stderr, "unknown batch queue type: %s\n", optarg); return EXIT_FAILURE; } break; case 't': worker_timeout = atoi(optarg); break; case 'w': workers_min = atoi(optarg); break; case 'W': workers_max = atoi(optarg); break; case LONG_OPT_TASKS_PER_WORKER: tasks_per_worker = atof(optarg); break; case 'E': extra_worker_args = optarg; break; case LONG_OPT_CORES: num_cores_option = xxstrdup(optarg); break; case LONG_OPT_MEMORY: num_memory_option = xxstrdup(optarg); break; case LONG_OPT_DISK: num_disk_option = xxstrdup(optarg); break; case LONG_OPT_GPUS: num_gpus_option = xxstrdup(optarg); break; case 'P': password_file = optarg; break; case 'S': scratch_dir = optarg; break; case 'c': consider_capacity = 1; break; case 'd': debug_flags_set(optarg); break; case 'o': debug_config_file(optarg); break; case 'O': debug_config_file_size(string_metric_parse(optarg)); break; case 'v': cctools_version_print(stdout, argv[0]); exit(EXIT_SUCCESS); case 'h': show_help(argv[0]); exit(EXIT_SUCCESS); default: show_help(argv[0]); return EXIT_FAILURE; } } cctools_version_debug(D_DEBUG, argv[0]); if(batch_queue_type == BATCH_QUEUE_TYPE_UNKNOWN) { fprintf(stderr,"work_queue_pool: You must specify a batch type with the -T option.\n"); fprintf(stderr, "valid options:\n"); fprintf(stderr, "%s\n", batch_queue_type_string()); return 1; } if(!project_regex) { fprintf(stderr,"work_queue_pool: You must give a project name with the -M option.\n"); return 1; } if(workers_min>workers_max) { fprintf(stderr,"work_queue_pool: --min-workers (%d) is greater than --max-workers (%d)\n",workers_min,workers_max); return 1; } if(tasks_per_worker < 1) { tasks_per_worker = num_cores_option ? atof(num_cores_option) : 1; } if(!scratch_dir) { scratch_dir = string_format("/tmp/wq-pool-%d",getuid()); } if(!create_dir(scratch_dir,0777)) { fprintf(stderr,"work_queue_pool: couldn't create %s: %s",scratch_dir,strerror(errno)); return 1; } char cmd[1024]; sprintf(cmd,"cp \"$(which work_queue_worker)\" '%s'",scratch_dir); if (system(cmd)) { fprintf(stderr, "work_queue_pool: please add work_queue_worker to your PATH.\n"); exit(EXIT_FAILURE); } if(password_file) { sprintf(cmd,"cp %s %s/pwfile",password_file,scratch_dir); system(cmd); } if(chdir(scratch_dir)!=0) { fprintf(stderr,"work_queue_pool: couldn't chdir to %s: %s",scratch_dir,strerror(errno)); return 1; } signal(SIGINT, handle_abort); signal(SIGQUIT, handle_abort); signal(SIGTERM, handle_abort); signal(SIGHUP, ignore_signal); struct batch_queue * queue = batch_queue_create(batch_queue_type); if(!queue) { fprintf(stderr,"work_queue_pool: couldn't establish queue type %s",batch_queue_type_to_string(batch_queue_type)); return 1; } set_worker_resources( queue ); mainloop( queue, project_regex, foremen_regex ); batch_queue_delete(queue); return 0; }
static void show_help(const char *cmd) { printf("Use: work_queue_pool [options]\n"); printf("where options are:\n"); printf(" %-30s Project name of masters to serve, can be a regular expression.\n", "-M,--master-name=<project>"); printf(" %-30s Foremen to serve, can be a regular expression.\n", "-F,--foremen-name=<project>"); printf(" %-30s Batch system type (required). One of: %s\n", "-T,--batch-type=<type>",batch_queue_type_string()); printf(" %-30s Password file for workers to authenticate to master.\n","-P,--password"); printf(" %-30s Minimum workers running. (default=%d)\n", "-w,--min-workers", workers_min); printf(" %-30s Maximum workers running. (default=%d)\n", "-W,--max-workers", workers_max); printf(" %-30s Average tasks per worker. (default=one task per core)\n", "--tasks-per-worker"); printf(" %-30s Workers abort after this amount of idle time. (default=%d)\n", "-t,--timeout=<time>",worker_timeout); printf(" %-30s Extra options that should be added to the worker.\n", "-E,--extra-options=<options>"); printf(" %-30s Set the number of cores requested per worker.\n", "--cores=<n>"); printf(" %-30s Set the number of GPUs requested per worker.\n", "--gpus=<n>"); printf(" %-30s Set the amount of memory (in MB) requested per worker.\n", "--memory=<mb> "); printf(" %-30s Set the amount of disk (in MB) requested per worker.\n", "--disk=<mb>"); printf(" %-30s Use this scratch dir for temporary files. (default is /tmp/wq-pool-$uid)\n","-S,--scratch-dir"); printf(" %-30s Use worker capacity reported by masters.","-c,--capacity"); printf(" %-30s Enable debugging for this subsystem.\n", "-d,--debug=<subsystem>"); printf(" %-30s Send debugging to this file. (can also be :stderr, :stdout, :syslog, or :journal)\n", "-o,--debug-file=<file>"); printf(" %-30s Show this screen.\n", "-h,--help"); }