Custom Hooks
Life cycle hooks are the script used to start / stop / monitor your apps by Brainlife. By default, it looks for executable installed on each resource in the PATH with named start
, status
, and stop
. Resource owner needs to make sure these scripts are installed and accessible by your apps.
For most PBS, SLURM, and vanilla VM, resource owner can install ABCD default hooks.
By default, the start
hook should look for a file named main
to start your app. Therefore, the only file required to make your app runnable by Brainlife is this main
executable on the root directory of the app's git repository.
Under most circumstances, app developers shouldn't have to worry about these hook scripts. However, if your app requires some special mechanism to start / stop and monitor your app, you might need to provide your own hook scripts.
You can specify the paths to these hook scripts by creating a file named package.json
1 2 3 4 5 6 7 |
|
Then, you will need to provide those hook scripts as part of your app.
Please be sure to
chmod +x *.sh
so that your hook scripts are executable.
start.sh
¶
Following is an example for the start
script. It submits a file named main (should be provided by each app) through qsub. It stores jobid
so that we can monitor the job status.
1 2 3 4 5 6 |
|
stop.sh
¶
Following is an example for the stop
script. This script reads the jobid created by the start
script and calls qdel to stop it.
1 2 |
|
status.sh
¶
The status hook is a bit more complicated. It needs to return various exit codes based on the status of the app. It uses the jobid
stored by start script to query the job status with qstat
PBS command.
Anything you output to stdout will be used to set the task's status message. For example, you can output the last line from the log file to relay the last log entry to the users on Brainlife.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|