File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ templates:
77 create-database.erb: bin/create-database
88 postgres.erb: bin/postgres
99 postgresql.conf.erb: config/postgresql.conf
10+ drain.erb: bin/drain
1011
1112packages:
1213 - postgres-10
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ # If a command fails, in a pipeline or not, exit immediately
4+ set -e -o pipefail
5+
6+ function prepend_datetime() {
7+ awk -W interactive ' { system("echo -n [$(date +%FT%T%z)]"); print " " $0 }'
8+ }
9+
10+ # Before redirecting stdout and stderr, copy the file descriptor for original
11+ # stdout where BOSH is expecting an integer, and only that.
12+ exec 3>&1
13+ exec \
14+ 1> >( prepend_datetime >> /var/vcap/sys/log/postgres-10/drain.out.log) \
15+ 2> >( prepend_datetime >> /var/vcap/sys/log/postgres-10/drain.err.log)
16+
17+ output_for_bosh () {
18+ exit_code=$?
19+
20+ if [ $exit_code -eq 0 ]; then
21+ echo " postgres-10 deamon is properly shutdown with Fast Shutdown mode (SIGINT)"
22+ else
23+ echo " drain failed"
24+ fi
25+
26+ echo $exit_code >&3
27+ }
28+
29+ trap output_for_bosh EXIT
30+
31+
32+ postgres_pid=$( /var/vcap/packages/bpm/bin/bpm pid postgres-10)
33+ kill -s SIGINT " ${postgres_pid} "
You can’t perform that action at this time.
0 commit comments