Skip to content

Commit

Permalink
Merge pull request #2578 from trshaffer/issue2577
Browse files Browse the repository at this point in the history
Add --parent-death to work_queue_factory
  • Loading branch information
Tim Shaffer authored Apr 1, 2021
2 parents 693dbde + e4e5975 commit 6cdb219
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
17 changes: 16 additions & 1 deletion batch_job/src/work_queue_factory.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ int using_catalog = 0;
static char *extra_worker_args=0;
static char *resource_args=0;
static int abort_flag = 0;
static pid_t initial_ppid = 0;
static const char *scratch_dir = 0;
static const char *password_file = 0;
static char *config_file = 0;
Expand Down Expand Up @@ -862,6 +863,11 @@ static void mainloop( struct batch_queue *queue )
int64_t factory_timeout_start = time(0);

while(!abort_flag) {
if (initial_ppid != 0 && getppid() != initial_ppid) {
printf("parent process exited, shutting down\n");
abort_flag = 1;
break;
}

if(config_file && !read_config_file(config_file)) {
debug(D_NOTICE, "Error re-reading '%s'. Using previous values.", config_file);
Expand Down Expand Up @@ -1060,6 +1066,7 @@ static void show_help(const char *cmd)
printf(" %-30s Specify the binary to use for the worker (relative or hard path). It should accept the same arguments as the default work_queue_worker.\n", "--worker-binary=<file>");
printf(" %-30s Will make a best attempt to ensure the worker will execute in the specified OS environment, regardless of the underlying OS.\n","--runos=<img>");
printf(" %-30s Force factory to run itself as a work queue manager.\n","--run-factory-as-manager");
fprintf(stdout, " %-30s Exit if parent process dies.\n", "--parent-death");
printf(" %-30s Show the version string.\n", "-v,--version");
printf(" %-30s Show this screen.\n", "-h,--help");
}
Expand Down Expand Up @@ -1087,6 +1094,7 @@ enum{ LONG_OPT_CORES = 255,
LONG_OPT_ENVIRONMENT_VARIABLE,
LONG_OPT_RUN_AS_MANAGER,
LONG_OPT_RUN_OS,
LONG_OPT_PARENT_DEATH,
};

static const struct option long_options[] = {
Expand Down Expand Up @@ -1119,6 +1127,7 @@ static const struct option long_options[] = {
{"mesos-path", required_argument, 0, LONG_OPT_MESOS_PATH},
{"mesos-preload", required_argument, 0, LONG_OPT_MESOS_PRELOAD},
{"min-workers", required_argument, 0, 'w'},
{"parent-death", no_argument, 0, LONG_OPT_PARENT_DEATH},
{"password", required_argument, 0, 'P'},
{"run-factory-as-manager", no_argument, 0, LONG_OPT_RUN_AS_MANAGER},
{"runos", required_argument, 0, LONG_OPT_RUN_OS},
Expand Down Expand Up @@ -1275,7 +1284,10 @@ int main(int argc, char *argv[])
consider_capacity = 1;
break;
case 'd':
debug_flags_set(optarg);
if (!debug_flags_set(optarg)) {
fprintf(stderr, "Unknown debug flag: %s\n", optarg);
exit(EXIT_FAILURE);
}
break;
case 'o':
debug_config_file(optarg);
Expand Down Expand Up @@ -1314,6 +1326,9 @@ int main(int argc, char *argv[])
case LONG_OPT_RUN_OS:
runos_os = xxstrdup(optarg);
break;
case LONG_OPT_PARENT_DEATH:
initial_ppid = getppid();
break;
default:
show_help(argv[0]);
return EXIT_FAILURE;
Expand Down
1 change: 1 addition & 0 deletions deltadb/src/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
deltadb_query
nvpair_to_json
deltadb_upgrade_log
catalog_server
1 change: 1 addition & 0 deletions tlq/client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jx_test
1 change: 1 addition & 0 deletions work_queue/src/bindings/python3/work_queue.binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -1690,6 +1690,7 @@ def __setattr__(self, name, value):

def _construct_command_line(self):
args = [self._factory_binary]
args += ['--parent-death']
args += ['--config-file', self._config_file]
args += ["--{}={}".format(opt, self._opts[opt])
for opt in self._opts
Expand Down

0 comments on commit 6cdb219

Please sign in to comment.