Last active
August 29, 2015 14:05
-
-
Save jdx/5614d6dae63a0341eb69 to your computer and use it in GitHub Desktop.
digital ocean node installation and stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yum update -y | |
yum install -y git nodejs npm vim | |
npm install -g n | |
n stable | |
node --version | |
git --version | |
vim /etc/yum.repos.d/mongodb.repo | |
[mongodb] | |
name=MongoDB Repository | |
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/ | |
gpgcheck=0 | |
enabled=1 | |
service mongod start | |
mongo | |
wget http://download.redis.io/releases/redis-2.8.13.tar.gz | |
tar -xvzf redis-2.8.13.tar.gz | |
cd redis-2.8.13 | |
make | |
make install | |
vim /etc/systemd/system/redis.service | |
[Service] | |
ExecStart=/usr/local/bin/redis-server | |
Restart=always | |
redis-cli | |
npm install --global gulp | |
su www | |
cd #/home/www | |
git clone https://github.com/dickeyxxx/mean-sample | |
vim /etc/systemd/system/mean-sample.service | |
[Service] | |
WorkingDirectory=/home/www/mean-sample | |
ExecStart=/usr/local/bin/npm start | |
User=www | |
Group=www | |
Restart=always | |
Environment='NODE_ENV=production' | |
StandardOutput=syslog | |
StandardError=syslog | |
SyslogIdentifier=mean-sample | |
#### LB | |
yum update -y | |
yum install -y git nodejs npm vim | |
npm install -g n | |
n stable | |
node --version | |
git --version | |
vim lb.js | |
var httpProxy = require('http-proxy') | |
var http = require('http') | |
var proxy = httpProxy.createProxyServer() | |
var urls = [ | |
'http://107.170.225.113:3000', | |
'http://107.170.225.114:3000' | |
] | |
function randomUrl() { | |
return urls[Math.floor(Math.random()*urls.length)] | |
} | |
var server = http.createServer(function (req, res) { | |
proxy.web(req, res, { target: randomUrl() }) | |
}) | |
server.on('upgrade', function (req, socket, head) { | |
proxy.ws(req, socket, head, { target: randomUrl() }); | |
}) | |
server.listen(80) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment