Skip to content

Commit 6cdb219

Browse files
author
Tim Shaffer
authored
Merge pull request #2578 from trshaffer/issue2577
Add --parent-death to work_queue_factory
2 parents 693dbde + e4e5975 commit 6cdb219

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

batch_job/src/work_queue_factory.c

+16-1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ int using_catalog = 0;
9191
static char *extra_worker_args=0;
9292
static char *resource_args=0;
9393
static int abort_flag = 0;
94+
static pid_t initial_ppid = 0;
9495
static const char *scratch_dir = 0;
9596
static const char *password_file = 0;
9697
static char *config_file = 0;
@@ -862,6 +863,11 @@ static void mainloop( struct batch_queue *queue )
862863
int64_t factory_timeout_start = time(0);
863864

864865
while(!abort_flag) {
866+
if (initial_ppid != 0 && getppid() != initial_ppid) {
867+
printf("parent process exited, shutting down\n");
868+
abort_flag = 1;
869+
break;
870+
}
865871

866872
if(config_file && !read_config_file(config_file)) {
867873
debug(D_NOTICE, "Error re-reading '%s'. Using previous values.", config_file);
@@ -1060,6 +1066,7 @@ static void show_help(const char *cmd)
10601066
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>");
10611067
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>");
10621068
printf(" %-30s Force factory to run itself as a work queue manager.\n","--run-factory-as-manager");
1069+
fprintf(stdout, " %-30s Exit if parent process dies.\n", "--parent-death");
10631070
printf(" %-30s Show the version string.\n", "-v,--version");
10641071
printf(" %-30s Show this screen.\n", "-h,--help");
10651072
}
@@ -1087,6 +1094,7 @@ enum{ LONG_OPT_CORES = 255,
10871094
LONG_OPT_ENVIRONMENT_VARIABLE,
10881095
LONG_OPT_RUN_AS_MANAGER,
10891096
LONG_OPT_RUN_OS,
1097+
LONG_OPT_PARENT_DEATH,
10901098
};
10911099

10921100
static const struct option long_options[] = {
@@ -1119,6 +1127,7 @@ static const struct option long_options[] = {
11191127
{"mesos-path", required_argument, 0, LONG_OPT_MESOS_PATH},
11201128
{"mesos-preload", required_argument, 0, LONG_OPT_MESOS_PRELOAD},
11211129
{"min-workers", required_argument, 0, 'w'},
1130+
{"parent-death", no_argument, 0, LONG_OPT_PARENT_DEATH},
11221131
{"password", required_argument, 0, 'P'},
11231132
{"run-factory-as-manager", no_argument, 0, LONG_OPT_RUN_AS_MANAGER},
11241133
{"runos", required_argument, 0, LONG_OPT_RUN_OS},
@@ -1275,7 +1284,10 @@ int main(int argc, char *argv[])
12751284
consider_capacity = 1;
12761285
break;
12771286
case 'd':
1278-
debug_flags_set(optarg);
1287+
if (!debug_flags_set(optarg)) {
1288+
fprintf(stderr, "Unknown debug flag: %s\n", optarg);
1289+
exit(EXIT_FAILURE);
1290+
}
12791291
break;
12801292
case 'o':
12811293
debug_config_file(optarg);
@@ -1314,6 +1326,9 @@ int main(int argc, char *argv[])
13141326
case LONG_OPT_RUN_OS:
13151327
runos_os = xxstrdup(optarg);
13161328
break;
1329+
case LONG_OPT_PARENT_DEATH:
1330+
initial_ppid = getppid();
1331+
break;
13171332
default:
13181333
show_help(argv[0]);
13191334
return EXIT_FAILURE;

deltadb/src/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
deltadb_query
22
nvpair_to_json
33
deltadb_upgrade_log
4+
catalog_server

tlq/client/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
jx_test

work_queue/src/bindings/python3/work_queue.binding.py

+1
Original file line numberDiff line numberDiff line change
@@ -1690,6 +1690,7 @@ def __setattr__(self, name, value):
16901690

16911691
def _construct_command_line(self):
16921692
args = [self._factory_binary]
1693+
args += ['--parent-death']
16931694
args += ['--config-file', self._config_file]
16941695
args += ["--{}={}".format(opt, self._opts[opt])
16951696
for opt in self._opts

0 commit comments

Comments
 (0)