Skip to content

Instantly share code, notes, and snippets.

View tjl2's full-sized avatar

Tim Littlemore tjl2

  • DICE
  • Cheshire, UK
  • 11:22 (UTC +01:00)
View GitHub Profile
def create_at_job
# Creates an at job to call our vm.kickstart_destroyer_url in 5 minutes (gives the
# installation chance to use the KS file)
unless @verbose
output = ">> /dev/null 2>&1"
else
output = ''
end
at_file = "/tmp/ksd-#{@name}"
`echo "wget -q #{@vm.kickstart_destroyer_url}; rm #{at_file}" > #{at_file}`

##Custom MySQL configs

If you need to customize the MySQL configuration, we provide methods to do this as outlined in our docs. Often, if people are making these changes with custom recipes, they usually follow up with a restart of MySQL via an execute call to /etc/init.d/mysql restart, or via a 'service' resource call with the 'restart' action. Often, this is done by people not realizing that Chef’s service notification methods can be used to conditionally restart MySQL, only if the custom configuration file has actually changed. The following snippet added into your custom recipe would make sure that MySQL is only restarted if your custom config template actually changed since the last run. It also allows for you to separate out your customizations based on whether they are dynamic or not (see our main MySQL configuration doc for a

#!/bin/sh
#
# This script starts and stops the Resque scheduler plugin daemon
# This script belongs in /engineyard/bin/resque
#
PATH=/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
usage() {
echo "Usage: $0 <appname> <env> {start|stop}"
exit 1
APP_ROOT=/data/core_batches/current
GEM_HOME=/data/core_batches/shared/bundled_gems/ruby/1.8
TERM=unknownSHELL=/bin/bash
IRBRC=/usr/local/rvm/rubies/ree-1.8.7-2012.02/.irbrc
MY_RUBY_HOME=/usr/local/rvm/rubies/ree-1.8.7-2012.02
USER=tmxcredit
SUDO_USER=root
SUDO_UID=0
rvm_path=/usr/local/rvm
QUEUE=*
#!/usr/bin/env bash
# This script controls the Resque daemon and belongs in /engineyard/bin/resque
original_path="$PWD"
#USE_RVM=true
#if [[ $USE_RVM == true ]]; then
# # TODO: change rvm path to /usr/local/rvm when moved
# PATH=/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/rvm/bin:$PATH
export PATH ; PATH="/usr/local/rvm/gems/ree-1.8.7-2012.02@core_batches/bin:/usr/local/rvm/gems/ree-1.8.7-2012.02@global/bin:/usr/local/rvm/rubies/ree-1.8.7-2012.02/bin:/usr/local/rvm/bin:$PATH"
export rvm_env_string ; rvm_env_string='ree-1.8.7-2012.02@core_batches'
export rvm_path ; rvm_path='/usr/local/rvm'
export rvm_ruby_string ; rvm_ruby_string='ree-1.8.7-2012.02'
export rvm_gemset_name ; rvm_gemset_name='core_batches'
export RUBY_VERSION ; RUBY_VERSION='ree-1.8.7-2012.02'
export GEM_HOME ; GEM_HOME='/usr/local/rvm/gems/ree-1.8.7-2012.02@core_batches'
export GEM_PATH ; GEM_PATH='/usr/local/rvm/gems/ree-1.8.7-2012.02@core_batches:/usr/local/rvm/gems/ree-1.8.7-2012.02@global'
export MY_RUBY_HOME ; MY_RUBY_HOME='/usr/local/rvm/rubies/ree-1.8.7-2012.02'
export IRBRC ; IRBRC='/usr/local/rvm/rubies/ree-1.8.7-2012.02/.irbrc'
@tjl2
tjl2 / resque.sh
Created February 11, 2013 16:42
Version of the /engineyard/bin/resque script that accepts an INTERVAL variable in resque_*.conf files
#!/bin/bash
# This script controls the Resque daemon and belongs in /engineyard/bin/resque
original_path="$PWD"
PATH=/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
usage() {
echo -e "
cmd="/usr/bin/env \$V \$VV APP_ROOT=\${application_root} RACK_ENV=\${environment} RAILS_ENV=\${environment} MERB_ENV=\${environment} ${queue_parameters[*]} ${RAKE:-'rake'} -f \${application_root}/Rakefile resque:work"
eval "sudo -u \$USER -H $cmd >> \$logfile 2>&1 &"

Local curl check

There are a couple fo ways to piece together the best URL to use when running a local curl check

If the customer has an HTTP monitor

  • Separate out the scheme, domain and path on the URL
  • Find out if we're a solo or within a cluster to find relevant port

If there is no HTTP monitor

  • Find the scheme and hostname to use from the relevant Nginx files
if ($host !~* www\.(.*)) {
set $host_with_www "www.$1";
rewrite ^(.*)$ $scheme://$host_with_www$request_uri permanent; #1
}