Permalink
Browse files

support for post-command hook to execute a script after every command

  • Loading branch information...
ssadedin committed Oct 8, 2017
1 parent abcaedc commit 041c59cd7caff63fbe6034fa477260b559f4cf53
View
@@ -229,6 +229,9 @@ set -o errexit
$mods_request
$command_prefix $COMMAND
$POST_CMD
HERE
echo $job_script_name
View
@@ -203,6 +203,9 @@ set -e;
$mods_request
cd \$PBS_O_WORKDIR
$COMMAND
$POST_CMD
HERE
echo $job_script_name
@@ -1,4 +1,4 @@
# Notifications in Bpipe
# Advanced Settings
## Introduction
@@ -45,6 +45,19 @@ jobs to launch this will make your whole pipeline take 9000 seconds to get start
need to balance the value of this setting against the capabilities and robustness of the
system the jobs are running on.
### Post Command Hook
If you want to run something every single time after each command finishes, you can set it as
a "post command" using the `post_cmd` configuration. For example, to print the date and time when
every command completes, in `bpipe.config`, you can put:
```
post_cmd="""
echo "Command finished at: `date`"
"""
```
*Note*: this is not supported by every executor, but is supported by most, including the local executor.
@@ -231,6 +231,9 @@ class CustomCommandExecutor implements CommandExecutor {
if(config?.custom)
env.CUSTOM = String.valueOf(config.custom)
if(config?.post_cmd)
env.POST_CMD = String.valueOf(config.post_cmd)
if(config?.nodes)
env.NODES = String.valueOf(config.nodes)
@@ -14,10 +14,15 @@ echo \$\$ > ${CMD_PID_FILE}
cat ${CMD_FILENAME} | bash -e
result=\$?
echo -n \$result > $jobDir/${CMD_EXIT_FILENAME}.tmp
mv $jobDir/${CMD_EXIT_FILENAME}.tmp $jobDir/${CMD_EXIT_FILENAME}
<%if(config?.post_cmd) {%>
${config.post_cmd}
<%}%>
#echo ">>>>>>>>>>>>>>>> EXITING COMMAND TEMPLATE <<<<<<<<<<<<<<<<<<<<<<"
exit \$result
@@ -22,4 +22,9 @@ bash -e ${CMD_FILENAME.absolutePath}
result=\$?
echo -n \$result > $jobDir/$CMD_EXIT_FILENAME
<%if(config?.post_cmd) {%>
${config.post_cmd}
<%}%>
exit \$result

0 comments on commit 041c59c

Please sign in to comment.