Permalink
Browse files

Updating for Heroku deployments.

  • Loading branch information...
1 parent 0ea5feb commit 79de4cd8db804e92386d11a004330dd5a58e9cb0 Josh Mervine committed Apr 9, 2015
Showing with 4 additions and 256 deletions.
  1. +0 −83 .nginx.conf
  2. +3 −63 Makefile
  3. +1 −0 Procfile
  4. +0 −35 make.js
  5. +0 −75 server.js
View
@@ -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:
View
@@ -1,68 +1,8 @@
# Simple Makefile wrappers to support 'make <task>' over 'node make <task>'.
# 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 $@
View
@@ -0,0 +1 @@
+web: node app.js
View
@@ -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');
@@ -50,38 +49,6 @@ var VALIDATOR = path.join(__dirname, 'node_modules/.bin/html-validator');
};
//
- // 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
//
target.travis = function() {
@@ -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');
};
View
@@ -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:

2 comments on commit 79de4cd

@XhmikosR
Member

...and how can one test locally stuff now?

@jmervine
Member

Yeah. This was an oversight. I need to revisit this.

Please sign in to comment.