openfrontier / docker-gerrit

Build a Docker image with the Gerrit code review system
Apache License 2.0
196 stars 118 forks source link

apk: Add procmail package #79

Closed kallisti5 closed 6 years ago

kallisti5 commented 6 years ago
thinkernel commented 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.

kallisti5 commented 6 years ago

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
thinkernel commented 6 years ago

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.