Skip to content

Commit

Permalink
Run post-start after app restart in restore script
Browse files Browse the repository at this point in the history
[#150976753] BBR restore script should restart credhub process after restore has finished
  • Loading branch information
ishustava committed Sep 13, 2017
1 parent 077a8fe commit ff7ae9c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 0 additions & 1 deletion jobs/credhub/templates/post-start.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ health_check() {
echo "Could not curl the credhub server"
return 1
fi
echo "json is $json" # TODO GROT
[ `echo $json | grep '"status":"UP"' | wc -l` -eq 1 ];
}

Expand Down
3 changes: 2 additions & 1 deletion jobs/credhub/templates/restore.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dbname = p('credhub.data_storage.database')

set -eu

export PATH=/var/vcap/bosh/bin:$PATH
export PATH=/var/vcap/bosh/bin:/var/vcap/jobs/credhub/bin:$PATH

<% if dbtype == "postgres" %>
export PG_PKG_DIR=/var/vcap/packages/postgres-9.4
Expand All @@ -27,6 +27,7 @@ ${PG_PKG_DIR}/bin/pg_restore \
--dbname="<%= dbname %>" "$BBR_ARTIFACT_DIRECTORY"/credhubdb_dump

monit restart credhub
post-start

<% else %>
echo "Skipping restore, as database is not Postgres"
Expand Down
11 changes: 6 additions & 5 deletions spec/spec/restore_erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ def render_restore_erb(dbtype="postgres")
' --dbname="example_credhub" "$BBR_ARTIFACT_DIRECTORY"/credhubdb_dump'
end

it "adds monit to $PATH" do
result = render_restore_erb("postgres", false)
expect(result).to include "export PATH=/var/vcap/bosh/bin:$PATH"
it "adds /var/vcap/bosh/bin and /var/vcap/jobs/credhub/bin to $PATH" do
result = render_restore_erb()
expect(result).to include "export PATH=/var/vcap/bosh/bin:/var/vcap/jobs/credhub/bin:$PATH"
end

it "restarts credhub" do
result = render_restore_erb("postgres", false)
it "restarts credhub and runs post-start" do
result = render_restore_erb()
expect(result).to include "monit restart credhub"
expect(result).to include "post-start"
end
end

Expand Down

0 comments on commit ff7ae9c

Please sign in to comment.