#!/usr/bin/env bash

# This is the default deliver strategy.
# It uses git push, rvm & foreman to generate upstart jobs

REQUIRED_CONFIGS+=(HOSTS)
OPTIONAL_CONFIGS+=(SUPERVISOR)

# Sincer deliver leverages foreman,
# it supports all the supervisors that foreman does
if [ -z "$SUPERVISOR" ]
then
  SUPERVISOR="upstart"
fi

# This function must be present since deliver will call it directly
# Everything inside it or around it is up to you
#
run() {
  authorize_hosts
  init_app_remotely
  git_push
  git_reset_remote
  authorize_remote_hosts
  git_submodules
  rvmrc_trust
  bundle_install
  foreman_export
  upstart
}
