Skip to content

Commit

Permalink
Merge pull request habitat-sh#28 from chef-cft/sm/fix-plan
Browse files Browse the repository at this point in the history
Update hooks
  • Loading branch information
jmery authored Jun 7, 2018
2 parents 5aa76c9 + ce5e986 commit 6a83c1a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 37 deletions.
6 changes: 4 additions & 2 deletions .studiorc
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ start_demo() {
}

start_mongodb() {
runcmd "hab pkg install $HAB_ORIGIN/np-mongodb"
runcmd "hab svc load $HAB_ORIGIN/np-mongodb"
}

start_parks() {
runcmd "hab pkg install $HAB_ORIGIN/national-parks"
runcmd "hab svc load $HAB_ORIGIN/national-parks --bind database:np-mongodb.default --channel stable --strategy at-once"
}

stop_mongodb() {
runcmd "hab svc stop $HAB_ORIGIN/np-mongodb"
runcmd "hab svc unload $HAB_ORIGIN/np-mongodb"
}

stop_parks() {
runcmd "hab svc stop $HAB_ORIGIN/national-parks"
runcmd "hab svc unload $HAB_ORIGIN/national-parks"
}

stop_demo() {
Expand Down
File renamed without changes.
File renamed without changes.
39 changes: 7 additions & 32 deletions habitat/hooks/init
Original file line number Diff line number Diff line change
@@ -1,40 +1,15 @@
#!/bin/bash -x

debug() {
if [ ! -z "$DEBUG" ]; then
echo "$*"
fi
}

echo "Preparing TOMCAT_HOME..."

debug "sys.ip = {{sys.ip}}"
debug "sys.hostname = {{sys.hostname}}"
debug "pkg.origin = {{pkg.origin}}"
debug "pkg.name = {{pkg.name}}"
debug "pkg.version = {{pkg.version}}"
debug "pkg.release = {{pkg.release}}"
debug "pkg.ident = {{pkg.ident}}"
debug "pkg.deps = {{pkg.deps}}"
debug "pkg.exposes = {{pkg.exposes}}"
debug "pkg.svc_path = {{pkg.svc_path}}"
debug "pkg.svc_config_path = {{pkg.svc_config_path}}"
debug "pkg.svc_data_path = {{pkg.svc_data_path}}"
debug "pkg.svc_files_path = {{pkg.svc_files_path}}"
debug "pkg.svc_static_path = {{pkg.svc_static_path}}"
debug "pkg.svc_var_path = {{pkg.svc_var_path}}"

# Move directories that ship in the package into place
# Copy directories that ship in the package into place
cp -a {{pkgPathFor "core/tomcat8"}}/tc {{pkg.svc_var_path}}/

# Copy our war file into the runtime tomcat directory
cp {{pkg.path}}/*.war {{pkg.svc_var_path}}/tc/webapps

# Following lines are to copy project tomcat configs to run time tomcat8 directory
for file in $(cd {{pkg.svc_config_path}}; ls -1 *.xml)
do
echo "Linking $file"
target="${file//_//}"
ln -vsf {{pkg.svc_config_path}}/$file {{pkg.svc_var_path}}/tc/$target
done

echo "Done preparing TOMCAT_HOME"
ln -vsf {{pkg.svc_config_path}}/server.xml {{pkg.svc_var_path}}/tc/conf/server.xml
ln -vsf {{pkg.svc_config_path}}/tomcat-users.xml {{pkg.svc_var_path}}/tc/conf/tomcat-users.xml
ln -vsf {{pkg.svc_config_path}}/webapps_host-manager_META-INF_context.xml {{pkg.svc_var_path}}/tc/conf/webapps_host-manager_META-INF_context.xml

echo "Done preparing TOMCAT_HOME"
5 changes: 2 additions & 3 deletions habitat/hooks/run
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ exec 2>&1

echo "Starting Apache Tomcat"

export JAVA_HOME=$(hab pkg path core/jre8)
export TOMCAT_HOME="$(hab pkg path core/tomcat8)/tc"
export JAVA_HOME=$(pkgPathFor core/jre8)
export TOMCAT_HOME="{{pkg.svc_var_path}}/tc"

{{#if bind.database ~}}
export CATALINA_OPTS="-DMONGODB_SERVICE_HOST={{bind.database.first.sys.ip}} -DMONGODB_SERVICE_PORT={{bind.database.first.cfg.port}}"
{{else ~}}
export CATALINA_OPTS="-DMONGODB_SERVICE_HOST={{cfg.mongodb_service_host}} -DMONGODB_SERVICE_PORT={{cfg.mongodb_service_port}}"
{{/if ~}}

cp {{pkg.path}}/*.war $TOMCAT_HOME/webapps

exec ${TOMCAT_HOME}/bin/catalina.sh run

0 comments on commit 6a83c1a

Please sign in to comment.