Skip to content

Instantly share code, notes, and snippets.

@armchairlinguist
Forked from ckraybill/deploy_hooks.yml
Last active May 29, 2020 21:50
Show Gist options
  • Save armchairlinguist/c863bde7e8ce8fe6ad4e244f82fd6a80 to your computer and use it in GitHub Desktop.
Save armchairlinguist/c863bde7e8ce8fe6ad4e244f82fd6a80 to your computer and use it in GitHub Desktop.
Cloud66 custom deploy hook for configuring papertrail to log application logs. These go in your `.cloud66` deployment folder.
production:
after_symlink:
- source: /.cloud66/log_files.yml
destination: /etc/log_files.yml
sudo: true
target: any
apply_during: all
- source: /.cloud66/remote_syslog.init.d
destination: /etc/init.d/remote_syslog
sudo: true
target: any
apply_during: all
- source: /.cloud66/papertrail.sh
destination: /tmp/papertrail.sh
target: any
sudo: true
execute: true
apply_during: build_only
- command: chmod +x /etc/init.d/remote_syslog && systemctl daemon-reload
sudo: true
target: any
execute: true
apply_during: deploy_only
- command: service remote_syslog restart
sudo: true
target: any
execute: true
apply_during: deploy_only
destination:
host: logsN.papertrailapp.com # change N to your host
port: XXXXX # change XXXXX to your port
protocol: tls
#!/bin/bash
# Download and install the remote_syslog2 binary from papertrail
wget https://github.com/papertrail/remote_syslog2/releases/download/v0.19/remote_syslog_linux_amd64.tar.gz
tar xzf ./remote_syslog*.tar.gz
mv remote_syslog remote_syslog_dir
cd remote_syslog_dir
sudo cp ./remote_syslog /usr/local/bin
# Set it up as a service (assumes init script has already been cp'd)
sudo chmod +x /etc/init.d/remote_syslog
sudo service remote_syslog start
sudo update-rc.d remote_syslog defaults
#!/bin/bash
source /var/.cloud66_env
### BEGIN INIT INFO
# Provides: remote_syslog
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and Stop
# Description: Runs remote_syslog
### END INIT INFO
# /etc/init.d/remote_syslog
#
# Starts the remote_syslog daemon
#
# chkconfig: 345 90 5
# description: Runs remote_syslog
#
# processname: remote_syslog
prog="remote_syslog"
config="/etc/log_files.yml"
pid_dir="/var/run"
EXTRAOPTIONS="$STACK_BASE/shared/log/*.log"
pid_file="$pid_dir/$prog.pid"
PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
RETVAL=0
is_running(){
[ -e $pid_file ]
}
start(){
echo -n $"Starting $prog: "
unset HOME MAIL USER USERNAME
$prog -c $config --pid-file=$pid_file $EXTRAOPTIONS
RETVAL=$?
echo
return $RETVAL
}
stop(){
echo -n $"Stopping $prog: "
if (is_running); then
kill `cat $pid_file`
RETVAL=$?
echo
return $RETVAL
else
echo "$pid_file not found"
fi
}
status(){
echo -n $"Checking for $pid_file: "
if (is_running); then
echo "found"
else
echo "not found"
fi
}
reload(){
restart
}
restart(){
stop
start
}
condrestart(){
is_running && restart
return 0
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
reload)
reload
;;
condrestart)
condrestart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
RETVAL=1
esac
exit $RETVAL
@kcollignon
Copy link

kcollignon commented Oct 19, 2017

Hi I am receiving this error when then trying to deploy my cloud66 stack, systemctl: command not found on ubuntu 14.04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment