How to deploy node to production

16,163 views

Published on

Published in: Technology
3 Comments
20 Likes
Statistics
Notes
  • I love this.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • where's the beef?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • node를 통해서 배포하는 과정을 보니 매우 스마트하게 처리되는것을 볼 수 있다. 역시 초기 아키텍처 과정에서 부터 scale을 고려해서 접근한다면 손쉽게 확장 가능한 웹서비스 구현이 가능하다는 얘기
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
16,163
On SlideShare
0
From Embeds
0
Number of Embeds
157
Actions
Shares
0
Downloads
92
Comments
3
Likes
20
Embeds 0
No embeds

No notes for slide
  • quick intro to topic\n
  • long-time consultant\nCofounder of i.TV\n
  • make TV amazing. \ncool announcements\nused node in production for 2 years. STORY. We picked it because we thought it was cool.\n\n
  • this is going to be a walk-through\ninterrupt me\n
  • front-end developers?\ngotten a node app working on your computer?\ndeployed a node or ruby app to production by hand before?\n\n
  • WALKTHROUGH. \nfollow a company. some of the steps are wrong, but we will explain why and show how to correct them.\nWe’re going to follow the story of a budding young entreprenuer\nBegin the story: local js meetup. talk on semicolons\n\n
  • \n
  • \n
  • because you know and like javascript, and you heard it scales\nDOES have a big advantage: JS Skills\n
  • All the real companies use .NET\nAfter a 3 hour meeting with your partner, you finally convince him to leave the decision to you and head out to learn. \n
  • \n
  • you don’t make a new one each time a requests. Only will work if it’s on and plugged in, ready to go. Listens on a socket. Different than PHP.\nIf we Control-C the program stops. \n
  • \n
  • * we’ll show off some cool stuff later\n
  • nice thing is they are all the same, so you can jump between providers depending on cost\n
  • domain name? (hosts file)\nSet up the server, and show how to log in. \nSwitch to VM?\n\n
  • \n
  • \n
  • \n
  • \n
  • Add a non-root user\ninstall nodejs (source: google)\n
  • Add a non-root user\ninstall nodejs (source: google)\n
  • Add a non-root user\ninstall nodejs (source: google)\n
  • Add a non-root user\ninstall nodejs (source: google)\n
  • Add a non-root user\ninstall nodejs (source: google)\n
  • Add a non-root user\ninstall nodejs (source: google)\n
  • Add a non-root user\ninstall nodejs (source: google)\n
  • Add a non-root user\ninstall nodejs (source: google)\n
  • Add a non-root user\ninstall nodejs (source: google)\n
  • Add a non-root user\ninstall nodejs (source: google)\n
  • Add a non-root user\ninstall nodejs (source: google)\n
  • Add a non-root user\ninstall nodejs (source: google)\n
  • Add a non-root user\ninstall nodejs (source: google)\n
  • Add a non-root user\ninstall nodejs (source: google)\n
  • get it running online\n
  • \n
  • demo it!\neven if you run it in the background\n
  • DEMO!\n
  • The “boss” makes you tell him how to edit the app. He breaks it. \n
  • Demo using git to deploy. (checkout, public)\ngit clone git://github.com/seanhess/ratinatorly.git\n
  • intro to npm\nshow how to deploy without copying node_modules\nuse npm init\nexpress: \n
  • \n
  • \n
  • \n
  • tell the story\n
  • \n
  • DEMO init script\nDEMO deploying with init script\n
  • montastic.com\n
  • when it crashes\nuncaught exception\nlogs\n
  • DEMO redirect with upstart\nDEMO track down the bug\nCan add fancy log analysis later\n
  • DEMO: show the uncaughtException code\n
  • \n
  • \n
  • DEMO: bash automated deploy\nNOPASSWD in sudoers (sudo visudo)\nsave fancier stuff for later when you have multiple servers (node-control, capistrano)\n
  • \n
  • DEMO: paste in the cluster code from the real one and check it closely\n\nvar os = require('os')\nvar cluster = require('cluster')\nif (cluster.isMaster) {\n\n for (var i = 0; i < os.cpus().length; i++) {\n cluster.fork()\n }\n}\nelse {\n app.listen(3333)\n console.log("Listening on 3333")\n}\n\n
  • DEMO\nsudo apt-get install varnish\nsudo vim /etc/default/varnish\nsudo vim /etc/varnish/default.vcl\nsudo /etc/init.d/varnish start\n\n
  • \n
  • heroku create --stack cedar\ngit push heroku master\nchange the port! (check the logs)\n
  • \n
  • \n
  • \n
  • \n
  • DEMO IT!\n
  • DEMO IT!\n
  • DEMO IT!\n
  • DEMO IT!\n
  • DEMO IT!\n
  • DEMO IT!\n
  • How to deploy node to production

    1. 1. HOW TO DEPLOY NODEwithout getting fired
    2. 2. @seanhessseanhess.github.com
    3. 3. Try it yourself deploynode.tk user public pass publicssh public@deploynode.tk
    4. 4. WHO AREYOU?
    5. 5. from FIRST STEPS to MISSTEPS toSCALE
    6. 6. Ratinatorlywho RATES the RATE-MEN?
    7. 7. SALARY is for chumps100,000shares of sweat-equity
    8. 8. you decide to try
    9. 9. Your First Node“but my brother saysthat .NET is the best language”
    10. 10. var express = require(express)var app = express.createServer()app.get(/, function(req, res) { res.send("Hello World!")})app.listen(3333)console.log("Listening on 3333")
    11. 11. your app is aLONG RUNNINGPROCESSit handles all the requests ...if it’s on
    12. 12. the PROTOTYPE ONLINE must be“Sequoia is going to LOVE this”
    13. 13. SHARED HOSTING FAIL *you need to run a PROGRAM
    14. 14. VPS WIN! like a cheapDEDICATED SERVER
    15. 15. sudo make me a server okay...
    16. 16. > ssh root@ratinator.lyroot@ratinatorlys password:Welcome to Ubuntu 11.04 (GNU/Linux# adduser node# adduser node sudo# sudo apt-get install python-software-properties# sudo apt-add-repository ppa:chris-lea/node.js# sudo apt-get update# sudo apt-get install nodejs npm
    17. 17. MAKE IT GO•copy our code• node app.js
    18. 18. DON’T CLOSE the LID!!“I didn’t do anything... Check Energy Saver”
    19. 19. your app BELONGS to your ssh sessionLOG OUT == DIE
    20. 20. SCREEN you keeps LOGGED IN
    21. 21. Undo! Rollback!“I know enough HTML to be dangerous”
    22. 22. let’s addVERSION CONTROL use GIT to deploy
    23. 23. manage yourDEPENDENCIES package.json > npm install
    24. 24. a PROCESS emerges• git commit and push• log in to server• pull• npm install• restart
    25. 25. LAUNCH!“I’ve got Techcrunch right where I want them”
    26. 26. port 80• must run as root
    27. 27. This is where I stop trying to design my slides
    28. 28. It keeps DYING! “Maybe we should trywindows servers instead”
    29. 29. upstart• OS will start on boot• Respawn
    30. 30. monitoring• know if it goes down
    31. 31. It works for me!or, when the cracks first began to show...
    32. 32. logging• keep your output
    33. 33. uncaughtExceptionprocess.on(“uncaughtException”, function(err) { console.log(err.message)})
    34. 34. Don’t forget step 6!“Will you put my changes up for me?”
    35. 35. complicated deploy• it can get easy to miss a step
    36. 36. automated• keep the knowledge in your code base• put extra stuff in package.json “install”
    37. 37. Too Slow!“Let’s just throw more money at this"
    38. 38. Multiple Processes• cluster up to your cores
    39. 39. Varnish Cache • avoid repeating work • set headers and gosudo apt-get install varnishsudo vim /etc/default/varnish # port 80sudo vim /etc/varnish/default.vcl # point to our app at port 3333sudo /etc/init.d/varnish start
    40. 40. Staging Box
    41. 41. cheat with Heroku• it’s easy, but can be expensive
    42. 42. Scale“We should aim for... 100 million users”
    43. 43. Multiple Servers• more app servers• varnish and db on separate box• use node-control to deploy• smart db = good for a long time
    44. 44. automate rem emwith erb UPSTARTand GITor CHEATwith HEROKU
    45. 45. seanhess.github.com @seanhess
    46. 46. > npm install express...> lsapp.js node_modules> node app.jsListening on 3333

    ×