Life cycles hooks are the script used to start / stop / monitor your apps by Brain-Life. 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 vanila VM, resource owner can install ABCD default hooks.
By default, start hook should look for a file named main to start your app. Therefore, the only file required to make your app runnable by Brain-Life 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.
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.
Following is an example for 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.
#return code 0 = job started successfully.
Following is an example for stop script. This scripts reads the jobid created by start script and call qdel to stop it.
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 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 Brain-Life.
echo "no jobid - not yet submitted?"
echo "jobid is empty.. failed to submit?"
echo "Job removed before completing - maybe timed out?"
echo "finished with code 0"
echo "finished with code $exit_status"
echo "unknown job status $jobstate .. will check later"