diff --git a/.nginx.conf b/.nginx.conf deleted file mode 100644 index 9a4523bc6..000000000 --- a/.nginx.conf +++ /dev/null @@ -1,83 +0,0 @@ -# While this comment exists, this nginx configuration is yet untested. - -user root; -worker_processes 1; - -error_log /home/CURRENT_USER/bootstrap-cdn/logs/error.log; -pid /var/run/nginx.pid; - -events { - worker_connections 1024; -} - -http { - include /home/CURRENT_USER/bootstrap-cdn/mime.types; - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - server_names_hash_bucket_size 64; - - access_log /home/CURRENT_USER/bootstrap-cdn/logs/access.log main; - sendfile on; - keepalive_timeout 65; - - gzip on; - gzip_comp_level 4; - gzip_disable "msie6"; - gzip_proxied any; - gzip_vary on; # Adds 'Vary: Accept-Encoding' - # Manually adding this for 'User-Agent' - - server_tokens off; - - upstream nodeapp { - server 127.0.0.1:3333 fail_timeout=10s slow_start=10s max_fails=3; - - # Because this file is used both on dev and test, if dev fails it will - # not backup anywhere. - server dev.bootstrapcdn.com backup; - } - - server { - listen 80 default_server; - server_name _; - - # Should be more then large enough, revisit if getting 413 errors. - client_max_body_size 4m; - - root /home/CURRENT_USER/bootstrap-cdn/public; - - expires 30d; - - add_header X-Powered-By "MaxCDN"; - add_header X-Hello-Human "You must be bored. You should work for us. Email jdorfman+theheader@maxcdn.com or @jdorfman on the twitter."; - - # Quick fix because root isn't working as expected, revisit - # because this is a really ugly way of doing it. - location /bootswatch/ { - root /home/CURRENT_USER/bootstrap-cdn/public; - } - location /bootstrap/ { - root /home/CURRENT_USER/bootstrap-cdn/public; - } - location /twitter-bootstrap/ { - root /home/CURRENT_USER/bootstrap-cdn/public; - } - location /font-awesome/ { - root /home/CURRENT_USER/bootstrap-cdn/public; - } - - location / { - proxy_pass http://nodeapp; - } - } - server { - server_name bootstrapcdn.com; - return 301 http://www.bootstrapcdn.com$request_uri; - } -} - -# vim: ft=nginx: diff --git a/Makefile b/Makefile index ac043fffc..63093b7b3 100644 --- a/Makefile +++ b/Makefile @@ -1,68 +1,8 @@ # Simple Makefile wrappers to support 'make ' over 'node make '. # This is a simple solution to avoid rewriting deployment automation. ### - -all: - node make all - -test: - node make test - -test-nc: - node make test-nc - -travis: test bootlint validator - -clean: - node make clean - run: - node make run - -start: - node make start - -stop: - node make stop - -restart: - node make restart - -status: - node make status - -help: - node make help - -bootlint: - node make bootlint - -validator: - node make validator - -wp-plugin: setup - node make wp-plugin - -### -# Tasks which remain in Makefile only. -### - -setup: - npm run setup - -nginx/start: - sudo /usr/local/nginx/sbin/nginx -c /home/$(USER)/bootstrap-cdn/nginx.conf - -nginx/stop: - sudo pkill -9 nginx - -nginx/restart: nginx/stop nginx/start - -nginx/reload: nginx/clean nginx.conf - sudo pkill -HUP nginx - -nginx.conf: - sed -e "s/CURRENT_USER/$(USER)/g" .nginx.conf > nginx.conf + node make $@ -nginx/clean: - rm nginx.conf +%: + node make $@ diff --git a/Procfile b/Procfile new file mode 100644 index 000000000..e1d4131b0 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: node app.js diff --git a/make.js b/make.js index d867303db..2a3bf65a8 100644 --- a/make.js +++ b/make.js @@ -5,7 +5,6 @@ var path = require('path'); var http = require('http'); var fs = require('fs'); -var FOREVER = path.join(__dirname, 'node_modules/.bin/forever'); var MOCHA = path.join(__dirname, 'node_modules/.bin/mocha'); var BOOTLINT = path.join(__dirname, 'node_modules/.bin/bootlint'); var VALIDATOR = path.join(__dirname, 'node_modules/.bin/html-validator'); @@ -49,38 +48,6 @@ var VALIDATOR = path.join(__dirname, 'node_modules/.bin/html-validator'); assertExec('node app.js'); }; - // - // make start - // - target.start = function() { - if (!test('-e', 'logs')) { - mkdir('logs'); - } - env.NODE_ENV = 'production'; - assertExec(FOREVER + ' -p ./logs -l server.log --append --plain start server.js', { async: true }); - }; - - // - // make stop - // - target.stop = function() { - assertExec(FOREVER + ' stop server.js'); - }; - - // - // make restart - // - target.restart = function() { - assertExec(FOREVER + ' restart server.js'); - }; - - // - // make status - // - target.status = function() { - assertExec(FOREVER + ' list'); - }; - // // make travis // @@ -198,8 +165,6 @@ var VALIDATOR = path.join(__dirname, 'node_modules/.bin/html-validator'); echo(' test-nc runs the tests w/o colors'); echo(' clean cleanup working directory'); echo(' run runs for development mode'); - echo(' start start application deamonized'); - echo(' stop stop application when deamonized'); echo(' bootlint run Bootlint locally'); echo(' help shows this help message'); }; diff --git a/server.js b/server.js deleted file mode 100644 index acb4e1dea..000000000 --- a/server.js +++ /dev/null @@ -1,75 +0,0 @@ -'use strict'; - -/** - * Libraries - **/ -var cluster = require('cluster'); -var datefmt = require('dateformat'); -var os = require('os'); - -/** - * Setup - **/ -var env = process.env.NODE_ENV; -var cores = os.cpus().length; -if (env === 'production') { - cores = cores === 1 ? cores : cores - 1; -} else { - cores = cores > 1 ? cores / 2 : cores; -} - -var workers = parseInt(process.env.CLUSTER_WORKERS || cores, 10); - -cluster.setupMaster({ exec: 'app.js' }); - -/** - * Utilities - **/ -var restartCount = 0; - -function say(message) { - console.log('[SERVER] ' + message); -} - -function checkRestart() { - if (restartCount >= 8) { - say('FATAL: Too many restarts in too short a time.'); - process.exit(1); - } - restartCount = 0; -} -setInterval(checkRestart, 2000); - -/** - * Startup Messaging - **/ -say('Master starting:'); -say('time => ' + datefmt(new Date(), 'ddd, dd mmm yyyy hh:MM:ss Z')); -say('pid => ' + process.pid); -say('environment => ' + env); - -/** - * Fork Workers - **/ -say('Workers starting:'); - -for (var i = 0; i < workers; i += 1) { - cluster.fork(); -} - -/** - * Worker Event Handlers - **/ -cluster.on('exit', function (worker) { - say('worker => with pid: ' + - worker.process.pid + - ', died. Restarting...'); - restartCount++; - cluster.fork(); -}); - -cluster.on('online', function (worker) { - say('worker => start with pid: ' + worker.process.pid + '.'); -}); - -// vim: ft=javascript sw=4 sts=4 et: