Last active
December 9, 2015 22:58
-
-
Save mlconnor/4340707 to your computer and use it in GitHub Desktop.
Node notes
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
# my node AMI - IMAGE ami-bcccb2d5 | |
on beanstalk, you can see node logs at /var/log/nodejs/nodejs.log | |
on beanstalk, if you proxy via nginx, check those logs here /var/log/nginx/error.log | |
proper way to make a mod to a repo and grab it with npm (http://debuggable.com/posts/how-to-fork-patch-npm-modules:4e2eb9f3-e584-44be-b1a9-3db7cbdd56cb) | |
Fork the project on GitHub | |
Clone the fork to your machine | |
Fix the bug or add the feature you want | |
Push your commits up to your fork on GitHub | |
Open your fork on GitHub, and click on the latest commit you made | |
Use npm to install the node via git://github.com/mlconnor/repo#COMMIT_ID | |
# if you create a project in your local directory, you need to create a package.json | |
# file if you want to do local npm installs. otherwise it will go into the parent directory | |
# or some weird other place. | |
# it looks like this enables you to build an RPM for node.js. https://github.com/kazuhisya/nodejs-rpm | |
# good tutorial- http://iconof.com/blog/how-to-install-setup-node-js-on-amazon-aws-ec2-complete-guide/ | |
# securing your ec2 instance - http://aws.amazon.com/articles/1233 | |
# running node.js as a service forever - http://www.exratione.com/2011/07/running-a-nodejs-server-as-a-service-using-forever/ | |
# running node.js as a service using upstart - http://howtonode.org/deploying-node-upstart-monit | |
# download linux binaries and decompress them into destination folder | |
# curl http://nodejs.org/dist/v0.10.12/node-v0.10.12-linux-x64.tar.gz | tar xz --strip-components=1 --directory=/home/ec2-user/node | |
# environment vars are set from different places. first are those set in /etc/profile. after that, the /etc/profile.d is run and then the bash_p | |
# echo -e "export PATH=/home/ec2-user/node/bin:\$PATH\nexport NODE_PATH=/home/ec2-user/node/lib/node_modules" | sudo tee -a /etc/profile.d/node.sh | |
ec2-run-instances ami-1624987f -k KO_Keypair --instance-type m1.small -z us-east-1a | |
ec2-describe-instances | grep INSTANCE | grep running | |
ssh -i AWS_KEY_FILE ec2-user@MACHINE_NAME.compute-1.amazonaws.com | |
# let's update this machine so that it has all of the latest software and security patches | |
sudo yum update | |
# let's grab all the dependencies we need to build and operate node | |
sudo yum install gcc-c++ make openssl-devel git | |
mkdir ~/node | |
cd ~/node | |
# let's download the most recent version of node and extract it into the ~/node directory | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
# configure the build for this operating system and environment | |
./configure | |
# now we build node. grab some coffee. this will take a while. | |
make | |
# now we install it on this computer | |
sudo make install | |
# i'm going to cleanup the node directory now | |
sudo rm -rf ~/node | |
# save a named ami from a running instance - http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-ebs.html | |
ec2-create-image -n "AWS Linux 64-bit EBS with Node.js v0.10.13" i-YOUR_MACHINE_INSTANCE_HERE | |
# one blog suggested configuration this way to get node automatically on your path ./configure --prefix=/usr | |
# change routing to from port 80 to port 8000 or node | |
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000 | |
# user forever to run the service indefinitely | |
# a nice chat example using socket.io - https://github.com/ericraio/socket.io-chat-demo | |
npm install forever -g | |
or | |
sudo /usr/local/bin/npm install forever -g | |
# install and run redis as a service on amazon | |
http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/ | |
# shell script that will build and install redis as a service | |
https://gist.github.com/2776679 | |
# if you are using the bodyParser, you can do nested parameters like this... | |
http://localhost:8000/test.do?foo[bar]=1&foo[baz]=2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment