Permalink
Browse files

[test] nodester

  • Loading branch information...
0 parents commit b70fab769b05ab31fec57c15a562e52420615660 @alejandro alejandro committed Jun 14, 2012
Showing with 18,438 additions and 0 deletions.
  1. +172 −0 app.js.js
  2. +12 −0 coffee.js
  3. +101 −0 index.html
  4. +1 −0 node_modules/.bin/express
  5. +7 −0 node_modules/express/.npmignore
  6. +811 −0 node_modules/express/History.md
  7. +22 −0 node_modules/express/LICENSE
  8. +29 −0 node_modules/express/Makefile
  9. +145 −0 node_modules/express/Readme.md
  10. +417 −0 node_modules/express/bin/express
  11. +2 −0 node_modules/express/index.js
  12. +510 −0 node_modules/express/lib-cov/application.js
  13. +65 −0 node_modules/express/lib-cov/express.js
  14. +54 −0 node_modules/express/lib-cov/middleware.js
  15. +225 −0 node_modules/express/lib-cov/request.js
  16. +611 −0 node_modules/express/lib-cov/response.js
  17. +40 −0 node_modules/express/lib-cov/router/collection.js
  18. +515 −0 node_modules/express/lib-cov/router/index.js
  19. +9 −0 node_modules/express/lib-cov/router/methods.js
  20. +68 −0 node_modules/express/lib-cov/router/route.js
  21. +151 −0 node_modules/express/lib-cov/utils.js
  22. +81 −0 node_modules/express/lib-cov/view.js
  23. +79 −0 node_modules/express/lib/express.js
  24. +582 −0 node_modules/express/lib/http.js
  25. +52 −0 node_modules/express/lib/https.js
  26. +323 −0 node_modules/express/lib/request.js
  27. +460 −0 node_modules/express/lib/response.js
  28. +53 −0 node_modules/express/lib/router/collection.js
  29. +398 −0 node_modules/express/lib/router/index.js
  30. +79 −0 node_modules/express/lib/router/methods.js
  31. +88 −0 node_modules/express/lib/router/route.js
  32. +152 −0 node_modules/express/lib/utils.js
  33. +460 −0 node_modules/express/lib/view.js
  34. +40 −0 node_modules/express/lib/view/partial.js
  35. +210 −0 node_modules/express/lib/view/view.js
  36. +11 −0 node_modules/express/node_modules/connect/.npmignore
  37. +24 −0 node_modules/express/node_modules/connect/LICENSE
  38. +2 −0 node_modules/express/node_modules/connect/index.js
  39. +81 −0 node_modules/express/node_modules/connect/lib/cache.js
  40. +106 −0 node_modules/express/node_modules/connect/lib/connect.js
  41. +218 −0 node_modules/express/node_modules/connect/lib/http.js
  42. +47 −0 node_modules/express/node_modules/connect/lib/https.js
  43. +46 −0 node_modules/express/node_modules/connect/lib/index.js
  44. +93 −0 node_modules/express/node_modules/connect/lib/middleware/basicAuth.js
  45. +196 −0 node_modules/express/node_modules/connect/lib/middleware/bodyParser.js
  46. +163 −0 node_modules/express/node_modules/connect/lib/middleware/compiler.js
  47. +46 −0 node_modules/express/node_modules/connect/lib/middleware/cookieParser.js
  48. +105 −0 node_modules/express/node_modules/connect/lib/middleware/csrf.js
  49. +222 −0 node_modules/express/node_modules/connect/lib/middleware/directory.js
  50. +100 −0 node_modules/express/node_modules/connect/lib/middleware/errorHandler.js
  51. +76 −0 node_modules/express/node_modules/connect/lib/middleware/favicon.js
  52. +80 −0 node_modules/express/node_modules/connect/lib/middleware/limit.js
  53. +299 −0 node_modules/express/node_modules/connect/lib/middleware/logger.js
  54. +38 −0 node_modules/express/node_modules/connect/lib/middleware/methodOverride.js
  55. +100 −0 node_modules/express/node_modules/connect/lib/middleware/profiler.js
  56. +40 −0 node_modules/express/node_modules/connect/lib/middleware/query.js
  57. +34 −0 node_modules/express/node_modules/connect/lib/middleware/responseTime.js
  58. +379 −0 node_modules/express/node_modules/connect/lib/middleware/router.js
  59. +345 −0 node_modules/express/node_modules/connect/lib/middleware/session.js
  60. +126 −0 node_modules/express/node_modules/connect/lib/middleware/session/cookie.js
  61. +131 −0 node_modules/express/node_modules/connect/lib/middleware/session/memory.js
  62. +137 −0 node_modules/express/node_modules/connect/lib/middleware/session/session.js
  63. +87 −0 node_modules/express/node_modules/connect/lib/middleware/session/store.js
  64. +225 −0 node_modules/express/node_modules/connect/lib/middleware/static.js
  65. +175 −0 node_modules/express/node_modules/connect/lib/middleware/staticCache.js
  66. +44 −0 node_modules/express/node_modules/connect/lib/middleware/vhost.js
  67. +79 −0 node_modules/express/node_modules/connect/lib/patch.js
  68. +75 −0 node_modules/express/node_modules/connect/lib/public/directory.html
  69. +13 −0 node_modules/express/node_modules/connect/lib/public/error.html
  70. BIN node_modules/express/node_modules/connect/lib/public/favicon.ico
  71. BIN node_modules/express/node_modules/connect/lib/public/icons/page.png
  72. BIN node_modules/express/node_modules/connect/lib/public/icons/page_add.png
  73. BIN node_modules/express/node_modules/connect/lib/public/icons/page_attach.png
  74. BIN node_modules/express/node_modules/connect/lib/public/icons/page_code.png
  75. BIN node_modules/express/node_modules/connect/lib/public/icons/page_copy.png
  76. BIN node_modules/express/node_modules/connect/lib/public/icons/page_delete.png
  77. BIN node_modules/express/node_modules/connect/lib/public/icons/page_edit.png
  78. BIN node_modules/express/node_modules/connect/lib/public/icons/page_error.png
  79. BIN node_modules/express/node_modules/connect/lib/public/icons/page_excel.png
  80. BIN node_modules/express/node_modules/connect/lib/public/icons/page_find.png
  81. BIN node_modules/express/node_modules/connect/lib/public/icons/page_gear.png
  82. BIN node_modules/express/node_modules/connect/lib/public/icons/page_go.png
  83. BIN node_modules/express/node_modules/connect/lib/public/icons/page_green.png
  84. BIN node_modules/express/node_modules/connect/lib/public/icons/page_key.png
  85. BIN node_modules/express/node_modules/connect/lib/public/icons/page_lightning.png
  86. BIN node_modules/express/node_modules/connect/lib/public/icons/page_link.png
  87. BIN node_modules/express/node_modules/connect/lib/public/icons/page_paintbrush.png
  88. BIN node_modules/express/node_modules/connect/lib/public/icons/page_paste.png
  89. BIN node_modules/express/node_modules/connect/lib/public/icons/page_red.png
  90. BIN node_modules/express/node_modules/connect/lib/public/icons/page_refresh.png
  91. BIN node_modules/express/node_modules/connect/lib/public/icons/page_save.png
  92. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white.png
  93. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_acrobat.png
  94. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_actionscript.png
  95. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_add.png
  96. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_c.png
  97. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_camera.png
  98. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_cd.png
  99. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_code.png
  100. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_code_red.png
  101. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_coldfusion.png
  102. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_compressed.png
  103. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_copy.png
  104. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_cplusplus.png
  105. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_csharp.png
  106. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_cup.png
  107. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_database.png
  108. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_delete.png
  109. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_dvd.png
  110. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_edit.png
  111. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_error.png
  112. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_excel.png
  113. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_find.png
  114. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_flash.png
  115. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_freehand.png
  116. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_gear.png
  117. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_get.png
  118. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_go.png
  119. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_h.png
  120. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_horizontal.png
  121. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_key.png
  122. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_lightning.png
  123. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_link.png
  124. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_magnify.png
  125. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_medal.png
  126. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_office.png
  127. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_paint.png
  128. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_paintbrush.png
  129. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_paste.png
  130. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_php.png
  131. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_picture.png
  132. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_powerpoint.png
  133. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_put.png
  134. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_ruby.png
  135. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_stack.png
  136. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_star.png
  137. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_swoosh.png
  138. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_text.png
  139. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_text_width.png
  140. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_tux.png
  141. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_vector.png
  142. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_visualstudio.png
  143. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_width.png
  144. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_word.png
  145. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_world.png
  146. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_wrench.png
  147. BIN node_modules/express/node_modules/connect/lib/public/icons/page_white_zip.png
  148. BIN node_modules/express/node_modules/connect/lib/public/icons/page_word.png
  149. BIN node_modules/express/node_modules/connect/lib/public/icons/page_world.png
  150. +141 −0 node_modules/express/node_modules/connect/lib/public/style.css
  151. +451 −0 node_modules/express/node_modules/connect/lib/utils.js
  152. +4 −0 node_modules/express/node_modules/connect/node_modules/formidable/.npmignore
  153. +4 −0 node_modules/express/node_modules/connect/node_modules/formidable/.travis.yml
  154. +14 −0 node_modules/express/node_modules/connect/node_modules/formidable/Makefile
  155. +311 −0 node_modules/express/node_modules/connect/node_modules/formidable/Readme.md
  156. +3 −0 node_modules/express/node_modules/connect/node_modules/formidable/TODO
  157. +70 −0 ..._modules/express/node_modules/connect/node_modules/formidable/benchmark/bench-multipart-parser.js
  158. +43 −0 node_modules/express/node_modules/connect/node_modules/formidable/example/post.js
  159. +48 −0 node_modules/express/node_modules/connect/node_modules/formidable/example/upload.js
  160. +1 −0 node_modules/express/node_modules/connect/node_modules/formidable/index.js
  161. +73 −0 node_modules/express/node_modules/connect/node_modules/formidable/lib/file.js
  162. +384 −0 node_modules/express/node_modules/connect/node_modules/formidable/lib/incoming_form.js
  163. +3 −0 node_modules/express/node_modules/connect/node_modules/formidable/lib/index.js
  164. +312 −0 node_modules/express/node_modules/connect/node_modules/formidable/lib/multipart_parser.js
  165. +25 −0 node_modules/express/node_modules/connect/node_modules/formidable/lib/querystring_parser.js
  166. +6 −0 node_modules/express/node_modules/connect/node_modules/formidable/lib/util.js
  167. +4 −0 node_modules/express/node_modules/connect/node_modules/formidable/node-gently/Makefile
  168. +167 −0 node_modules/express/node_modules/connect/node_modules/formidable/node-gently/Readme.md
  169. +22 −0 node_modules/express/node_modules/connect/node_modules/formidable/node-gently/example/dog.js
  170. +11 −0 ...modules/express/node_modules/connect/node_modules/formidable/node-gently/example/event_emitter.js
  171. +1 −0 node_modules/express/node_modules/connect/node_modules/formidable/node-gently/index.js
  172. +184 −0 node_modules/express/node_modules/connect/node_modules/formidable/node-gently/lib/gently/gently.js
  173. +1 −0 node_modules/express/node_modules/connect/node_modules/formidable/node-gently/lib/gently/index.js
  174. +14 −0 node_modules/express/node_modules/connect/node_modules/formidable/node-gently/package.json
  175. +8 −0 node_modules/express/node_modules/connect/node_modules/formidable/node-gently/test/common.js
  176. +348 −0 ...dules/express/node_modules/connect/node_modules/formidable/node-gently/test/simple/test-gently.js
  177. +29 −0 node_modules/express/node_modules/connect/node_modules/formidable/package.json
  178. +19 −0 node_modules/express/node_modules/connect/node_modules/formidable/test/common.js
  179. +1 −0 ..._modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/funkyfilename.txt
  180. +1 −0 node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/plain.txt
  181. +3 −0 .../node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/info.md
  182. +3 −0 node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/no-filename.js
  183. +21 −0 ...express/node_modules/connect/node_modules/formidable/test/fixture/js/special-chars-in-filename.js
  184. +72 −0 node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multipart.js
  185. +89 −0 node_modules/express/node_modules/connect/node_modules/formidable/test/integration/test-fixtures.js
  186. +24 −0 node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/common.js
  187. +80 −0 ...ess/node_modules/connect/node_modules/formidable/test/legacy/integration/test-multipart-parser.js
  188. +104 −0 node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-file.js
  189. +727 −0 ...les/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-incoming-form.js
  190. +50 −0 .../express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-multipart-parser.js
  191. +45 −0 ...xpress/node_modules/connect/node_modules/formidable/test/legacy/simple/test-querystring-parser.js
  192. +75 −0 ...xpress/node_modules/connect/node_modules/formidable/test/legacy/system/test-multi-video-upload.js
  193. +2 −0 node_modules/express/node_modules/connect/node_modules/formidable/test/run.js
  194. +63 −0 node_modules/express/node_modules/connect/node_modules/formidable/test/unit/test-incoming-form.js
  195. +47 −0 node_modules/express/node_modules/connect/node_modules/formidable/tool/record.js
  196. +49 −0 node_modules/express/node_modules/connect/package.json
  197. +19 −0 node_modules/express/node_modules/mime/LICENSE
  198. +50 −0 node_modules/express/node_modules/mime/README.md
  199. +92 −0 node_modules/express/node_modules/mime/mime.js
  200. +40 −0 node_modules/express/node_modules/mime/package.json
  201. +79 −0 node_modules/express/node_modules/mime/test.js
  202. +1,479 −0 node_modules/express/node_modules/mime/types/mime.types
  203. +43 −0 node_modules/express/node_modules/mime/types/node.types
  204. +2 −0 node_modules/express/node_modules/mkdirp/.gitignore.orig
  205. +5 −0 node_modules/express/node_modules/mkdirp/.gitignore.rej
  206. +2 −0 node_modules/express/node_modules/mkdirp/.npmignore
  207. +21 −0 node_modules/express/node_modules/mkdirp/LICENSE
  208. +54 −0 node_modules/express/node_modules/mkdirp/README.markdown
  209. +6 −0 node_modules/express/node_modules/mkdirp/examples/pow.js
  210. +6 −0 node_modules/express/node_modules/mkdirp/examples/pow.js.orig
  211. +19 −0 node_modules/express/node_modules/mkdirp/examples/pow.js.rej
  212. +79 −0 node_modules/express/node_modules/mkdirp/index.js
  213. +37 −0 node_modules/express/node_modules/mkdirp/package.json
  214. +38 −0 node_modules/express/node_modules/mkdirp/test/chmod.js
  215. +37 −0 node_modules/express/node_modules/mkdirp/test/clobber.js
  216. +28 −0 node_modules/express/node_modules/mkdirp/test/mkdirp.js
  217. +32 −0 node_modules/express/node_modules/mkdirp/test/perm.js
  218. +39 −0 node_modules/express/node_modules/mkdirp/test/perm_sync.js
  219. +41 −0 node_modules/express/node_modules/mkdirp/test/race.js
  220. +32 −0 node_modules/express/node_modules/mkdirp/test/rel.js
  221. +27 −0 node_modules/express/node_modules/mkdirp/test/sync.js
  222. +28 −0 node_modules/express/node_modules/mkdirp/test/umask.js
  223. +27 −0 node_modules/express/node_modules/mkdirp/test/umask_sync.js
  224. +6 −0 node_modules/express/node_modules/qs/.gitmodules
  225. +1 −0 node_modules/express/node_modules/qs/.npmignore
  226. +4 −0 node_modules/express/node_modules/qs/.travis.yml
  227. +73 −0 node_modules/express/node_modules/qs/History.md
  228. +5 −0 node_modules/express/node_modules/qs/Makefile
  229. +54 −0 node_modules/express/node_modules/qs/Readme.md
  230. +17 −0 node_modules/express/node_modules/qs/benchmark.js
  231. +51 −0 node_modules/express/node_modules/qs/examples.js
  232. +2 −0 node_modules/express/node_modules/qs/index.js
  233. +264 −0 node_modules/express/node_modules/qs/lib/querystring.js
  234. +30 −0 node_modules/express/node_modules/qs/package.json
  235. +2 −0 node_modules/express/node_modules/qs/test/mocha.opts
  236. +167 −0 node_modules/express/node_modules/qs/test/parse.js
  237. +103 −0 node_modules/express/node_modules/qs/test/stringify.js
  238. +74 −0 node_modules/express/package.json
  239. +41 −0 node_modules/express/test.js
  240. +20 −0 package.json
  241. BIN public/grad.png
  242. BIN public/rocket-md-right.png
  243. +6 −0 server.coffee
  244. +32 −0 server.js
172 app.js.js
@@ -0,0 +1,172 @@
+#!/usr/bin/env node
+
+require.paths.unshift('/usr/lib/node_modules');
+var spawn = require('child_process').spawn;
+var exec = require('child_process').exec;
+var daemon = require('daemon');
+var fs = require('fs');
+var path = require('path');
+var net = require('net');
+var node_versions = require('../lib/lib').node_versions();
+var config = JSON.parse(fs.readFileSync(path.join('.nodester', 'config.json'), encoding = 'utf8'));
+var cfg = require('../config').opt;
+var oldmask, newmask = 0000;
+oldmask = process.umask(newmask);
+console.log('Changed umask from: ' + oldmask.toString(8) + ' to ' + newmask.toString(8));
+var run_max = 5;
+var run_count = 0;
+var LOG_STDOUT = 1;
+var LOG_STDERR = 2;
+var env = {
+ PATH: '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin',
+ NODE_ENV: 'production'
+};
+if (config.env) {
+ Object.keys(config.env).forEach(function (key) {
+ env[key] = String(config.env[key]);
+ });
+}
+env.app_port = parseInt(config.port, 10);
+env.app_host = config.ip;
+var args = ['/app/' + config.start];
+var chroot_res = daemon.chroot(config.appchroot);
+if (chroot_res !== true) {
+ log_line('chroot_runner', 'Failed to chroot to ' + config.apphome, LOG_STDERR);
+ pre_shutdown();
+ process.exit(1);
+}
+var ch_uid = daemon.setreuid(config.userid);
+if (ch_uid !== true) {
+ log_line.call('chroot_runner', 'Failed to change user to ' + config.userid, LOG_STDERR);
+ pre_shutdown();
+ process.exit(2);
+}
+var child = null;
+var child_watcher_time = null;
+var log_lines = [];
+var myPid = daemon.start();
+(function () {
+ var log_listen = function (p, cb) {
+ var srv = net.createServer(function (conn) {
+ var logs = JSON.stringify({
+ logs: log_lines.join('\n')
+ });
+ conn.write(logs);
+ conn.end();
+ });
+ srv.listen(p, cb);
+ };
+ var log_line = function (line, stdout) {
+ if (typeof this == 'string') {
+ line = this + line;
+ }
+ log_lines.push(line);
+ if (log_lines.length > 150) log_lines.shift();
+ };
+ log_line.call('chroot_runner', 'New PID: ' + myPid.toString());
+ if (path.existsSync('/.nodester/pids/runner.pid')) fs.unlinkSync('/.nodester/pids/runner.pid');
+ fs.writeFileSync('/.nodester/pids/runner.pid', myPid.toString());
+ var log_sock_path = path.join('/', '.nodester', 'logs.sock');
+ log_listen(log_sock_path, function () {
+ log_line('chroot_runner', 'log_listen\'ing', LOG_STDERR);
+ try {
+ fs.chmodSync(log_sock_path, '0777');
+ } catch (e) {
+ log_line('chroot_runner', 'Failed to chmod logs.sock', LOG_STDERR);
+ }
+ process.on('SIGINT', function () {
+ log_line.call('chroot_runner', 'SIGINT recieved, sending SIGTERM to children.');
+ if (child !== null) {
+ log_line.call('chroot_runner', 'Child PID: ' + child.pid.toString());
+ process.kill(child.pid, 'SIGTERM');
+ process.exit();
+ } else {
+ process.exit();
+ }
+ });
+ process.on('SIGTERM', function () {
+ log_line.call('chroot_runner', 'SIGTERM recieved, sending SIGTERM to children.');
+ if (child !== null) {
+ log_line.call('chroot_runner', 'Child PID: ' + child.pid.toString());
+ process.kill(child.pid, 'SIGTERM');
+ process.exit();
+ } else {
+ process.exit();
+ }
+ });
+ var start_child = function () {
+ var pack = {};
+ // normalize path, since args contain the node-executable pop that value
+ // and replace it with `package.json`
+ // I'm not a RegExp guru so this is my solution ;)
+ var packPath = args[0].split('/');
+ packPath[packPath.length - 1] = 'package.json';
+ packPath = packPath.join('/');
+ // we don't know what kind of package.json are we dealing with
+ try {
+ pack = JSON.parse(fs.readFileSync(packPath, 'utf8'));
+ } catch (e) {
+ // Set default to the parent node version
+ pack['node'] = process.version;
+ }
+ // What if the try/catch read the package but there is no `node`?
+ var version = pack['node'] === undefined ? process.version : pack['node'];
+ // n dir only handles number paths without v0.x.x => 0.x.x
+ version = version.replace('v', '').trim();
+ // Insert node-watcher code and link the dependency
+ if (node_versions.indexOf(version) !== -1) {
+ // The spawn process only works with absolute paths, and by default n'd saved every
+ // version of node in /usr/local/n/version
+ var nodePath = '/usr/local/n/versions/' + version + '/bin/node'
+ var coffeePath = nodePath + ' /node/coffeelauncher';
+
+ log_line.call('data','Spawing ' + args[0], LOG_STDOUT);
+
+ child = spawn((path.extname(args[0]) == '.coffee' ? coffeePath : nodePath ), args, {
+ env: env
+ });
+
+ /*
+ * Check if the version of node is 0.4.x or <0.6.17
+ * because of:
+ * http://blog.nodejs.org/2012/05/07/http-server-security-vulnerability-please-upgrade-to-0-6-17/
+ */
+ var digits = parseFloat(version,10);
+ var WARN = '\033[1m\033[31mWARN\033[39m\033[22m';
+
+ if (digits < 0.6){
+ log_line.call('data', WARN +' :: You are running in node-'+ version +
+ '. You might want to upgrade to node-v0.6.17' ,LOG_STDERR);
+ } else if (digits === 0.6 && version.substr(-2) < 17){
+ log_line.call('data', WARN + ' :: You need to upgrade to 0.6.17 Change the value in your package.json',LOG_STDERR);
+ }
+
+ log_line.call('Watcher', 'Running node v-' + version, LOG_STDERR);
+ child.stdout.on('data', log_line.bind('stdout'));
+ child.stderr.on('data', log_line.bind('stderr'));
+ child.on('exit', function (code) {
+ if (code > 0 && run_count > run_max) {
+ log_line.call('Watcher', 'Error: Restarted too many times, bailing.', LOG_STDERR);
+ clearInterval(child_watcher_timer);
+ } else if (code > 0) {
+ log_line.call('Watcher', 'Process died with exit code ' + code + '. Restarting...', LOG_STDERR);
+ child = null;
+ } else {
+ log_line.call('Watcher', 'Process exited cleanly. Dieing.', LOG_STDERR);
+ clearInterval(child_watcher_timer);
+ }
+ });
+ } else {
+ log_line.call('Watcher', 'Process exited cleanly. node.js Version:' + version + ' not avaiable', LOG_STDERR);
+ clearInterval(child_watcher_timer);
+ }
+ };
+ var child_watcher = function () {
+ if (child === null) {
+ start_child();
+ run_count++;
+ }
+ };
+ child_watcher_timer = setInterval(child_watcher, 750);
+ });
+})();
@@ -0,0 +1,12 @@
+
+var app = process.argv[2] || 'server'
+ , path = require('path');
+
+ if (path.existsSync(app)){
+ require('coffee-script');
+ require(path.resolve(app));
+ } else {
+ console.log('not found',app);
+ process.kill(process.pid, 'SIGKILL')
+ }
+
@@ -0,0 +1,101 @@
+<!doctype html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Welcome to Nodester!</title>
+ <link href="http://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css">
+ <style>
+ * {
+ margin: 0;
+ }
+ html {
+ background: url(/grad.png);
+ font-family: Verdana,"Open Sans";
+ }
+ #rocket {
+ margin-left: auto;
+ margin-right: auto;
+ width: 8em;
+ top: 30px;
+ }
+ #rocket img {
+ height:150px;
+ padding-top: 3px;
+ margin-left: -10px;
+ }
+ .rocket {
+ margin-left: auto;
+ margin-right: auto;
+ width: 100%;
+ top:30px;
+ text-align:center;
+ }
+
+
+ a {
+ text-decoration:none;
+ }
+
+ .box {
+ width:27em;
+ padding:50px 10px 30px 10px;
+ margin-bottom: 45px;
+ border-top: 1px solid #C9C9C9;
+ border-left: 1px solid #C9C9C9;
+ border-right: 1px solid #C9C9C9;
+ background-color: white;
+ -webkit-box-shadow: #AAA 0px 1px 5px;
+ box-shadow: 0px 1px 5px #AAA;
+ -moz-box-shadow: 0px 1px 5px #AAA;
+ margin-top: 0px;
+ }
+ #wrapper form {
+ padding-top:2em;
+ }
+
+ #login-msg {
+ text-align: center;
+ color: green;
+ }
+ #login-status {
+ font-size: 0.7em;
+ text-align: left;
+ color: #500000;
+ width: 100%;
+ box-shadow: inset 0 0 5px
+ #CCC;
+ min-height: 10px;
+ background:whiteSmoke;
+ }
+ </style>
+</head>
+
+<div id="main-wrapper">
+ <div id="wrapper" class="rocket box">
+ <div id="rocket">
+ <img src="/rocket-md-right.png">
+ </div>
+ <div class="rocket">
+ <h2>Welcome to Nodester!</h2>
+ <br />
+ </div>
+ <div id="login-status">
+ <h3>Some stuff that you can do:</h3>
+ <ul>
+ <li>Replace the content on <code>server.js</code></li>
+ <li>play with this file (<code>index.html</code>)</li>
+ <li>About nodester:
+ <ul>
+ <li><a href="http://blog.nodester.com/post/3634535277/running-websockets-on-nodester">Websockets on nodester</a></li>
+ <li><a href="http://blog.nodester.com/post/19902515151/tips-for-windows-users">Tips for Windows Users</a></li>
+ <li>We run multiple node-versions. <a href="http://blog.nodester.com/post/18702499832/nodester-now-running-node-js-0-6-12">Learn how you can use it</a></li>
+ </ul>
+ </li>
+ </ul>
+ </div>
+ </div>
+
+</div>
+
+</body>
+</html>

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit b70fab7

Please sign in to comment.