0
Deploying Node.js           and staying sane  SYDJS   2011-02-16 18:00:00   MICHEIL SMITH
Quick IntroductionMicheil Smith •   An Engineer at Votizen (votizen.com) •   A core contributor to Node.js •   Current Nod...
What is Node.js• Evented I/O For V8 JavaScript• http://github.com/ry/node• http://nodejs.org         SYDJS   2011-02-16 18...
In other words, you can build some really awesome shit.   SYDJS   2011-02-16 18:00:00   MICHEIL SMITH
BUT!SYDJS   2011-02-16 18:00:00   MICHEIL SMITH
Deployment can be an utter pain in the ass.SYDJS   2011-02-16 18:00:00   MICHEIL SMITH
Why?SYDJS   2011-02-16 18:00:00   MICHEIL SMITH
• Git based deployment honestly sucks• Existing solutions do work, but aren’t perfect• Rolling it ourselves is too much wo...
Git based deploymenthonestly sucks•   Having multiple remotes isn’t much fun•   Repositories become out of sync•   Writing...
Existing solutions dowork, but aren’t perfectExisting tools require you to work outside ofJavaScript & don’t integrate wit...
Rolling it ourselves istoo much workNobody honestly wants to spend heaps of timewriting stuff just so they can get their c...
A WayForwardSYDJS   2011-02-16 18:00:00   MICHEIL SMITH
Look, Learn, Create• Other platforms have solutions• What do we need in deployment?• NPM exists, make use of it        SYD...
Other platforms havesolutionsJava: CruiseControlRuby: Capistrano, BundlerTwitter: MurderPython: Fabric       SYDJS   2011-...
What do we need in    deployment?•   Simple Configuration•   Versioning & Rollbacks•   Logs (well, duh, right?)•   Integra...
NPM exists, makeuse of itNPM is great: • It’s in the background • It can handle a lot of the hard work • Package.json files...
TheProposalSYDJS   2011-02-16 18:00:00   MICHEIL SMITH
`npm install deploy`The idea is to have a tool that: •   Doesn’t require too much setup •   Makes use of existing standard...
How’s it work? (part 1)• Made up of two components: • client-side CLI • server-side daemon        SYDJS   2011-02-16 18:00...
How’s it work? (part 2)Client-side: (Developer side)• The application directory has a deploy.json• A user or global .deplo...
deploy.jsonMuch like package.json, but contains: • which servers to deploy to • any dependencies that can’t be found on NP...
Example{    "name": "brandedcode-blog",    "repository": {       "type": "git",       "url": "git@github.com:miksago/brand...
Server-side .deployrcA json file, telling the daemon the following: • where to place code for certain sites • users from wh...
Example{    "users": {       "micheil": {          "salt": "...", "password": "..."       },       "mikeal": {          "s...
The server-side daemon•   A thin node net.Server•   Uses a protocol similar to netstrings + json•   Uses gzipped tarballs ...
When?SYDJS   2011-02-16 18:00:00   MICHEIL SMITH
Not yet.Over the next few months.https://github.com/votizen/deploy SYDJS   2011-02-16 18:00:00   MICHEIL SMITH
Other issues in deployment• Ensuring your server is always up• Managing settings & configuration• Binding to privileged po...
Ensuring your server is  always up• Use the tools that come with your OS, eg: • Ubuntu has upstart • Solaris has SMF • Deb...
Managing settings &configurationA few options available on the modules wiki page:https://github.com/ry/node/wiki/Modules  ...
Another way for Settings  Management• Keep settings & commonly done stuff as a central  module.• Use something like settin...
Binding to privileged ports  but not running as root?• Fairly easy to do with Node: • first start with a umask of 007 • bi...
Thanks for listeningSYDJS   2011-02-16 18:00:00   MICHEIL SMITH
• Votizen.com• Twittter: @miksago• Email: micheil@votizen.com     SYDJS   2011-02-16 18:00:00   MICHEIL SMITH
Anythoughts or questions? SYDJS   2011-02-16 18:00:00   MICHEIL SMITH
Upcoming SlideShare
Loading in...5
×

Sydjs – Deploying Node.js and Staying Sane

2,817

Published on

A talk given at a SYDJS.com meetup held at the Atlassian offices on Wednesday 16th, February 2011.

Audio has been recorded and will be released at some stage.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,817
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
18
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • examples: heroku, no.de, hosting it yourself\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript of "Sydjs – Deploying Node.js and Staying Sane"

    1. 1. Deploying Node.js and staying sane SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    2. 2. Quick IntroductionMicheil Smith • An Engineer at Votizen (votizen.com) • A core contributor to Node.js • Current Node.js Documentation Lead • Author of ‘node-websocket-server’ • Twittter: @miksago • Email: micheil@votizen.com SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    3. 3. What is Node.js• Evented I/O For V8 JavaScript• http://github.com/ry/node• http://nodejs.org SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    4. 4. In other words, you can build some really awesome shit. SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    5. 5. BUT!SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    6. 6. Deployment can be an utter pain in the ass.SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    7. 7. Why?SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    8. 8. • Git based deployment honestly sucks• Existing solutions do work, but aren’t perfect• Rolling it ourselves is too much work SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    9. 9. Git based deploymenthonestly sucks• Having multiple remotes isn’t much fun• Repositories become out of sync• Writing post-receive hooks is awful• Can only really push to one server at a time SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    10. 10. Existing solutions dowork, but aren’t perfectExisting tools require you to work outside ofJavaScript & don’t integrate with the node.jsecosystem. SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    11. 11. Rolling it ourselves istoo much workNobody honestly wants to spend heaps of timewriting stuff just so they can get their code intoproduction. SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    12. 12. A WayForwardSYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    13. 13. Look, Learn, Create• Other platforms have solutions• What do we need in deployment?• NPM exists, make use of it SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    14. 14. Other platforms havesolutionsJava: CruiseControlRuby: Capistrano, BundlerTwitter: MurderPython: Fabric SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    15. 15. What do we need in deployment?• Simple Configuration• Versioning & Rollbacks• Logs (well, duh, right?)• Integration with NPM SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    16. 16. NPM exists, makeuse of itNPM is great: • It’s in the background • It can handle a lot of the hard work • Package.json files are great, use them SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    17. 17. TheProposalSYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    18. 18. `npm install deploy`The idea is to have a tool that: • Doesn’t require too much setup • Makes use of existing standards & extends them • Doesn’t get in the way; you can do without it • Stand-alone, not part of an existing tool SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    19. 19. How’s it work? (part 1)• Made up of two components: • client-side CLI • server-side daemon SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    20. 20. How’s it work? (part 2)Client-side: (Developer side)• The application directory has a deploy.json• A user or global .deployrc fileServer-side:• A daemon for accepting deploys is running• A global .deployrc file SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    21. 21. deploy.jsonMuch like package.json, but contains: • which servers to deploy to • any dependencies that can’t be found on NPM • any scripts to be run at different phases of deployment • location of the source code repository SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    22. 22. Example{ "name": "brandedcode-blog", "repository": { "type": "git", "url": "git@github.com:miksago/brandedcode.git", "path": "./blog" }, "servers": [{ "host": "blog.brandedcode.com", "port": 49700, }], "dependencies": { "brandedcode-common": { "type": "git", "url": "git@github.com:miksago/brandedcode.git", "path": "./brandedcode-common" } }, "scripts": { "deploy": "scripts/deploy.js" }} SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    23. 23. Server-side .deployrcA json file, telling the daemon the following: • where to place code for certain sites • users from which to accept deploys • various other configuration SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    24. 24. Example{ "users": { "micheil": { "salt": "...", "password": "..." }, "mikeal": { "salt": "...", "password": "..." } }, "servers": { "brandedcode.com": { "users": ["micheil"], "path": "/home/micheil/sites/brandedcode.com/" }, "thenoded.com": { "users": ["mikeal", "micheil"], "path": "/home/deploy/sites/thenoded.com/" } }, "daemon": { "port": 4970 }} SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    25. 25. The server-side daemon• A thin node net.Server• Uses a protocol similar to netstrings + json• Uses gzipped tarballs to transfer files• Maintains logs and handles user management• Could use alternative file-transfer methods SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    26. 26. When?SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    27. 27. Not yet.Over the next few months.https://github.com/votizen/deploy SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    28. 28. Other issues in deployment• Ensuring your server is always up• Managing settings & configuration• Binding to privileged ports but not running as root? SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    29. 29. Ensuring your server is always up• Use the tools that come with your OS, eg: • Ubuntu has upstart • Solaris has SMF • Debian has Sysvconfig (can probably get Upstart)• Monitor your processes • Just to keep resources in check really. SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    30. 30. Managing settings &configurationA few options available on the modules wiki page:https://github.com/ry/node/wiki/Modules SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    31. 31. Another way for Settings Management• Keep settings & commonly done stuff as a central module.• Use something like settings.js: • https://gist.github.com/824688Ask me after the talk and I can go into further detail SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    32. 32. Binding to privileged ports but not running as root?• Fairly easy to do with Node: • first start with a umask of 007 • bind to the privileged port • use process.setgid() and process.setuid() to drop down privileges SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    33. 33. Thanks for listeningSYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    34. 34. • Votizen.com• Twittter: @miksago• Email: micheil@votizen.com SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    35. 35. Anythoughts or questions? SYDJS 2011-02-16 18:00:00 MICHEIL SMITH
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×