Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions habitat/config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"listen": {
"address": "{{cfg.listen.address}}",
"port": {{cfg.listen.port}}
},
"storage": {
"path": "{{cfg.storage.path}}"
}
}
6 changes: 6 additions & 0 deletions habitat/default.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[listen]
address = "0.0.0.0"
port = 8228

[storage]
path = "/srv/leverage/leverage.sqlite"
7 changes: 7 additions & 0 deletions habitat/hooks/init
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
ln -sf {{pkg.path}}/package.json {{pkg.svc_var_path}}
ln -sf {{pkg.path}}/app.js {{pkg.svc_var_path}}
ln -sf {{pkg.path}}/node_modules {{pkg.svc_var_path}}
ln -sf {{pkg.path}}/lib {{pkg.svc_var_path}}
ln -sf {{pkg.path}}/controllers {{pkg.svc_var_path}}
ln -sf {{pkg.svc_config_path}}/config.json {{pkg.svc_var_path}}
4 changes: 4 additions & 0 deletions habitat/hooks/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

cd {{pkg.svc_var_path}}
exec node app.js 2>&1
67 changes: 67 additions & 0 deletions habitat/plan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
pkg_origin=leverage
pkg_name=leverage-api
pkg_version=0.1.0
pkg_maintainer="Chris Alfano <chris@codeforphilly.org>"
pkg_license=(MIT)
pkg_upstream_url=https://github.com/Lever-age/api
pkg_source=leverage-api.tar.gz
pkg_deps=(bochener/node)
pkg_expose=(8228)
pkg_build_deps=(core/coreutils)

do_download() {
return 0
}

do_verify() {
return 0
}

do_unpack() {
return 0
}

do_prepare() {
# This hack deals with some npm package build scripts having
# /usr/bin/env hardcoded instead of using env from PATH by
# temporarily creating a symlink at /usr/bin/env within
# the build environment that links to the env executable
# provided by the coreutils package
#
# Habitat provides a minimal environment for builds where every
# available package has its bin folder added to PATH rather than
# its contents copied to a global /usr/bin directory

if [[ ! -r /usr/bin/env ]]; then
ln -sv "$(pkg_path_for coreutils)/bin/env" /usr/bin/env
_clean_env=true
fi
}

do_build() {
# Copy files from wherever this plan is being run from to the
# temporary build space for this package
cp -vr $PLAN_CONTEXT/../* $HAB_CACHE_SRC_PATH/$pkg_dirname

# cd into the temporary build space and populate node_modules/
cd $HAB_CACHE_SRC_PATH/$pkg_dirname
npm install
}

do_install() {
# Copy the things we want to distribute from the current
# directory (this package's temporary build space) to the
# root for this package's build
cp -v package.json ${pkg_prefix}
cp -v app.js ${pkg_prefix}
cp -vr controllers ${pkg_prefix}
cp -vr lib ${pkg_prefix}
cp -r node_modules ${pkg_prefix}
}

do_end() {
# Clean up the `env` link, if we set it up.
if [[ -n "$_clean_env" ]]; then
rm -fv /usr/bin/env
fi
}