Skip to content

Instantly share code, notes, and snippets.

View RaphaelAudet's full-sized avatar

Raphaël Audet RaphaelAudet

View GitHub Profile
@RaphaelAudet
RaphaelAudet / ghost-production.sh
Created October 27, 2014 15:44
Monit wrapper script for FOREVER running GHOST
#!/bin/bash
export NODE_ENV=production
NAME="ghost-$NODE_ENV"
USER="node"
APP_ROOT="/var/www/ghost"
PID_FILE="/var/www/ghost/$NAME.pid "
export PATH=$PATH:
@RaphaelAudet
RaphaelAudet / sleep_worker.rb
Last active August 29, 2015 14:07
app/workers/SleepWorker.rb a sleeping worker
class SleepWorker
@queue = :low
def self.perform(args)
sleep 300
end
end
@RaphaelAudet
RaphaelAudet / resque_alert.rb
Created September 30, 2014 13:16
Resque Stalled Alert : this script can check if a resque queue is overflowing or a job is "stuck"
require 'date'
require 'redis'
require 'net/smtp'
require 'resque'
require 'resque/version'
class App
VERSION = '0.0.1'
def initialize
@RaphaelAudet
RaphaelAudet / find_n_rm.sh
Created September 18, 2014 08:50
find and delete files
find . -type f -name "FILE-TO-FIND" -exec rm
@RaphaelAudet
RaphaelAudet / unicorn_production.conf
Created September 17, 2014 08:06
unicorn_production.conf
check process unicorn_production with pidfile /var/www/az_app_2_production/shared/pids/unicorn.pid
if totalmem > 2.6 GB for 5 cycles then restart
start = "/etc/az-scripts/unicorn_production.sh start" with timeout 90 seconds
stop = "/etc/az-scripts/unicorn_production.sh stop"
@RaphaelAudet
RaphaelAudet / clearredis.rb
Created August 28, 2014 12:58
clear sidekiq broken failed job after upgrading to sidekiq 3.1.4
redis = Redis.new(:host => 'xxxxx', :port => xxxxx, :password => 'xxxxxx', :thread_safe => true)
redis.llen("sidekiq:xxxxxxx:failed")
10.times {redis.lpop("sidekiq:xxxxxxx:failed")}
@RaphaelAudet
RaphaelAudet / filelimits.sh
Last active August 29, 2015 14:04
set open file limit
#!/bin/bash
cp /etc/sysctl.conf /etc/sysctl.conf.20140808
echo 'fs.file-max = 64000'>>/etc/sysctl.conf
echo 'root soft nofile 64000'>>/etc/security/limits.conf
echo 'root hard nofile 64000'>>/etc/security/limits.conf
# echo 'mongodb soft nofile 64000'>>/etc/security/limits.conf
# echo 'mongodb hard nofile 64000'>>/etc/security/limits.conf
sysctl -p
@RaphaelAudet
RaphaelAudet / settz.sh
Created July 25, 2014 13:01
set timezone
echo "Europe/Paris" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
@RaphaelAudet
RaphaelAudet / new_swap.sh
Last active August 29, 2015 14:04
add swap from scratch
#!/bin/bash
# http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/
dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
mkswap /swapfile1
chmod 0600 /swapfile1
echo '/swapfile1 swap swap defaults 0 0' >> /etc/fstab
#swapon -a
function tab-red() { tab-color 203 111 111; }
function tab-green() { tab-color 6cc276; }
function tab-yellow() { tab-color "#e8e9ac"; }
function tab-blue() { tab-color 6f8ccc; }
function tab-purple() { tab-color a789d4; }
function tab-orange() { tab-color fbbc79; }
function tab-white() { tab-color fff; }
function tab-gray() { tab-color c3c3c3c; }
tg() {tab-blue; ssh $1.europe-west1-b.MYPROJECT -t sudo tmux attach -t main;}