-
Notifications
You must be signed in to change notification settings - Fork 3
Add callback switch to mxqsub #172
Open
pmenzel
wants to merge
2
commits into
master
Choose a base branch
from
add-callback-switch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,10 @@ static void print_usage(void) | |
| " -e, --stderr=FILE set file to capture stderr (default: <stdout>)\n" | ||
| " -u, --umask=MASK set mode to use as umask (default: current umask)\n" | ||
| " -p, --priority=PRIORITY set priority (default: 127)\n" | ||
| " -c, --callback=SCRIPT execute SCRIPT when the job finishes (any outcome)\n" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically it doesn't need to be a SCRIPT, because we execl() whatever executable it is, right? |
||
| " runs as the submitting user in the job workdir;\n" | ||
| " MXQ_JOB_ID, MXQ_GROUP_ID, MXQ_JOB_STATUS, and\n" | ||
| " MXQ_JOB_WORKDIR are set in the environment\n" | ||
| "\n" | ||
| "Job resource information:\n" | ||
| " Scheduling is done based on the resources a job needs and\n" | ||
|
|
@@ -517,6 +521,7 @@ static int add_job(struct mx_mysql *mysql, struct mxq_job *j) | |
|
|
||
| " job_stdout = ?," | ||
| " job_stderr = ?," | ||
| " job_callback = ?," | ||
|
|
||
| " job_umask = ?," | ||
|
|
||
|
|
@@ -535,8 +540,9 @@ static int add_job(struct mx_mysql *mysql, struct mxq_job *j) | |
| mx_mysql_statement_param_bind(stmt, 4, string, &(j->job_argv_str)); | ||
| mx_mysql_statement_param_bind(stmt, 5, string, &(j->job_stdout)); | ||
| mx_mysql_statement_param_bind(stmt, 6, string, &(j->job_stderr)); | ||
| mx_mysql_statement_param_bind(stmt, 7, uint32, &(j->job_umask)); | ||
| mx_mysql_statement_param_bind(stmt, 8, string, &(j->host_submit)); | ||
| mx_mysql_statement_param_bind(stmt, 7, string, &(j->job_callback)); | ||
| mx_mysql_statement_param_bind(stmt, 8, uint32, &(j->job_umask)); | ||
| mx_mysql_statement_param_bind(stmt, 9, string, &(j->host_submit)); | ||
|
|
||
| res = mx_mysql_statement_execute(stmt, &num_rows); | ||
| if (res < 0) { | ||
|
|
@@ -705,6 +711,7 @@ int main(int argc, char *argv[]) | |
| char arg_debug; | ||
| u_int32_t arg_tmpdir; | ||
| u_int16_t arg_gpu; | ||
| char *arg_callback; | ||
|
|
||
| _mx_cleanup_free_ char *current_workdir = NULL; | ||
| _mx_cleanup_free_ char *arg_stdout_absolute = NULL; | ||
|
|
@@ -769,6 +776,7 @@ int main(int argc, char *argv[]) | |
| MX_OPTION_REQUIRED_ARG("prerequisites", 10), | ||
| MX_OPTION_REQUIRED_ARG("tags", 11), | ||
| MX_OPTION_NO_ARG("gpu", 12), | ||
| MX_OPTION_REQUIRED_ARG("callback", 'c'), | ||
| MX_OPTION_END | ||
| }; | ||
|
|
||
|
|
@@ -798,6 +806,7 @@ int main(int argc, char *argv[]) | |
| arg_prerequisites = ""; | ||
| arg_tags = NULL; | ||
| arg_gpu = 0; | ||
| arg_callback = ""; | ||
|
|
||
| arg_mysql_default_group = getenv("MXQ_MYSQL_DEFAULT_GROUP"); | ||
| if (!arg_mysql_default_group) | ||
|
|
@@ -1021,6 +1030,18 @@ int main(int argc, char *argv[]) | |
| case 12: | ||
| arg_gpu = 1; | ||
| break; | ||
|
|
||
| case 'c': | ||
| if (!(*optctl.optarg)) { | ||
| mx_log_crit("--callback '%s': String is empty.", optctl.optarg); | ||
| exit(EX_CONFIG); | ||
| } | ||
| if (optctl.optarg[0] != '/') { | ||
| mx_log_crit("--callback '%s': must be an absolute path.", optctl.optarg); | ||
| exit(EX_CONFIG); | ||
| } | ||
| arg_callback = optctl.optarg; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1133,6 +1154,7 @@ int main(int argc, char *argv[]) | |
| job.job_argc = argc; | ||
| job.job_argv = argv; | ||
| job.job_argv_str = arg_args; | ||
| job.job_callback = arg_callback; | ||
|
|
||
| /******************************************************************/ | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ALTER TABLE mxq_job | ||
| ADD COLUMN job_callback VARCHAR(4096) NOT NULL DEFAULT '' AFTER job_stderr; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we blocking the daemon here while the user script does its
sleep infinityor whatever?