Skip to content

Instantly share code, notes, and snippets.

View lucianosousa's full-sized avatar
💭
🏊 🚴‍♂️ 🏃

Luciano Sousa lucianosousa

💭
🏊 🚴‍♂️ 🏃
View GitHub Profile
@lucianosousa
lucianosousa / gist:f914cbde9aa63703cd17
Created May 31, 2015 17:06
nginx daemon for ubuntu
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: nginx init.d dash script for Ubuntu <=9.10.
# Description: nginx init.d dash script for Ubuntu <=9.10.
### END INIT INFO
* * * * * /bin/bash -l -c 'sh /home/ec2-user/scripts/monitor.sh postgresql93 redis-server nginx memcached >> /var/log/cron 2>&1'
* * * * * /bin/bash -l -c 'sleep 30; sh /home/ec2-user/scripts/monitor.sh postgresql93 redis-server nginx memcached >> /var/log/cron 2>&1'
@lucianosousa
lucianosousa / gist:e6d8353ce0abe38f6ae1
Created May 31, 2015 16:39
check if sidekiq is running
#!/bin/bash
echo "starting check sidekiq"
process=`cat /path-to/sidekiq.pid`
processConfirmation=`ps aux | awk '{print $2 }' | grep $process`
if [ -z $processConfirmation ]
then
echo "oops! not running... restarting sidekiq"
@lucianosousa
lucianosousa / gist:f11de784eec44fcd5f4d
Created May 31, 2015 16:36
check if service is running
#!/bin/bash
commands=("$@")
echo "starting monitor check"
for command in "${commands[@]}"; do
if [ $command == "postgresql93" ]
then
check="postmaster"
$ cat ~/.bashrc
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
ruby-2.2.1 | objet (master)
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable
@lucianosousa
lucianosousa / nginx
Last active August 29, 2015 14:14
nginx script as process on centOS
#!/bin/sh
#
# nginx – this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /opt/nginx/conf/nginx.conf
# pidfile: /opt/nginx/logs/nginx.pid
@lucianosousa
lucianosousa / redis-server
Last active August 29, 2015 14:14 — forked from tahajahangir/redis-server
redis-server - a config file to put on /etc/init.d/redis-server and set as centOS service
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid
@lucianosousa
lucianosousa / redis.conf
Created January 29, 2015 02:34
/etc/redis/redis.conf for amazon linux/centOS - redis as daemon/service
daemonize yes
pidfile /var/run/redis.pid
port 6379
tcp-backlog 511
bind 127.0.0.1
timeout 0
tcp-keepalive 0
loglevel notice
logfile "/var/log/redis.log"
databases 16
pg_dump -U user-name -d database-name -W > backup.sql
scp user-name@server-address:path-to-file my-path