Closed kallisti5 closed 6 years ago
Hi there. Before I can add this into the image, would you like to give me some examples about how you want to use it in the Gerrit. I'm asking because Gerrit has it's own options for email notifications which is satisfied on my needs. I wounder in which case notifications need to be triggered by hooks.
Our case is we tag an incremental tag on every push. We use the lockfiles to ensure proper ordering and ensure we only trigger one instance of post-receive scripts at a time.
Example:
#! /bin/bash
lockfile=$GIT_DIR/hrev.lock
with_lock_unlock_if_held() {
if [[ "$with_lock_has_lock" -eq 1 ]] ; then
rm -f "$lockfile"
fi
}
# grab lockfile to protect against concurrent post-receive
# hooks getting confused with the order of hrevs
with_lock_has_lock=0
trap with_lock_unlock_if_held INT TERM EXIT
lockfile -1 -r 30 "$lockfile"
if [ $? -ne 0 ] ; then
exit $?
fi
with_lock_has_lock=1
# fetch input in tempfile
FILE=$(mktemp)
cat - >$FILE
# create hrev-tags and send e-mail & cia notifications
cat $FILE | $GIT_DIR/hooks/post-receive.pl
# tell buildbot about new changes
cat $FILE | $GIT_DIR/hooks/git_buildbot.py
# drop tempfile
rm $FILE
# cleanup lockfile
rm -f "$lockfile"
with_lock_has_lock=0
Fair enough. Pay attention to the multi-processes in container. Java process is the pid 1 in container currently. There's no intention of switching it to any process manager like the supervisord currently.