Skip to content

Instantly share code, notes, and snippets.

View dstroot's full-sized avatar
:octocat:
Slingin' Code

Dan Stroot dstroot

:octocat:
Slingin' Code
View GitHub Profile
@dstroot
dstroot / ec2_install_node.sh
Created March 25, 2012 01:13
An EC2 setup script to install Node.js
#!/bin/bash
echo "*****************************************"
echo " get superuser and install all updates "
echo "*****************************************"
sudo su
yum –y update
echo "*****************************************"
echo " Installing Development Tools"
echo "*****************************************"
yum install gcc gcc-c++ make -y
@dstroot
dstroot / install-mongo.sh
Created March 25, 2012 17:38
Install MongoDB on Amazon EC2
#!/bin/bash
echo "*****************************************"
echo " Add the 10gen repository - after you press"
echo " enter add the following lines and then"
echo " cntl-X to save:"
echo " [10gen]"
echo " name=10gen Repository"
echo " baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64"
echo " gpgcheck=0"
echo "*****************************************"
From Hack Sparrow:
---------------------------
Some time ago, I wrote a post on keeping Node.js apps running even after logging out from the shell. It was cool and all, but soon you will soon realize that Forever alone is not enough. Because, on system reboots, Forever itself is killed. Who will restart your app now?
There are many options for handling this kind of scenario, but today we will implement a solution using cron. Let's find out how we can make Forever and our Node.js app reboot-proof.
The app you want Forever to start on system restart is probably a web app, so let's try this thing on an Express.js web app.
Install Express, if you haven't already:
$ npm install -g express
@dstroot
dstroot / ec2-mysql-installation.sh
Created May 23, 2012 16:55
Install mysql on amazon EC2 AMI
#!/bin/bash
###############################################
# To use:
# https://raw.github.com/gist/2776351/5fc6f3a63450ff6986ac916fce54d70c16937646/ec2-mysql-installation.sh
# chmod 777 install-redis.sh# ./install-redis.sh
###############################################
echo "*****************************************"
echo " Installing MySQL"
echo "*****************************************"
echo " "
@dstroot
dstroot / install-redis.sh
Created May 23, 2012 17:56
Install Redis on Amazon EC2 AMI
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://raw.github.com/gist/2776679/04ca3bbb9f085b192f6aca945120fe12d59f15f9/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"
@dstroot
dstroot / redis-server
Created May 23, 2012 20:03 — forked from tessro/redis-server
An Amazon AMI initscript for Redis
#!/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
@dstroot
dstroot / reboot.sh
Created May 23, 2012 20:58
script to start forever after reboot
#!/bin/sh
if [ $(ps aux | grep $USER | grep node | grep -v grep | wc -l | tr -s "\n") -eq 0 ]
then
export NODE_ENV=production
export PATH=/usr/local/bin:$PATH
forever start ~/vizilinkz/server.js > /dev/null
# redirects port 80 to port 8080
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
fi
@dstroot
dstroot / install_reboot.sh
Created May 23, 2012 21:03
install forever reboot script
#!/bin/bash
echo "*****************************************"
echo " Download the script and add to crontab "
echo "*****************************************"
sudo wget https://raw.github.com/gist/2777778/e92dc28e3f3961e0e2740d262b3ed884a11f6f85/reboot.sh
sudo chmod 777 reboot.sh
sudo line="@reboot ~/reboot.sh >> cron.log 2>&1"
sudo (crontab -l; echo "$line" ) | crontab -
sudo checkconfg crond on
@dstroot
dstroot / master_install.sh
Created May 23, 2012 21:14
master install script
#!/bin/bash
###############################################
# To use:
# wget https://raw.github.com/gist/2776679/c131c0548e7cd2ece85edfb8bea70575586147c7/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"
echo " Get superuser and install all updates "
echo "*****************************************"
@dstroot
dstroot / curl.sh
Created May 24, 2012 23:59
curl command to test site speed
curl -w "\nTotal time: %{time_total}\nTime pretransfer: %{time_pretransfer}\nTime starttransfer: %{time_starttransfer}\nSize download: %{size_download}\n Speed download: %{speed_download}" www.vizilinkz.com