Skip to content

Setting up Pepyatka

epicmonkey edited this page Sep 28, 2013 · 12 revisions

Prerequisites

  • Install redis
  • Install graphicsmagick (ensure jpeg and png flags are set)
  • Install nodejs
  • Install elasticsearch (and java as a dependency ;-)
  • Install graphicsmagick library

Configuration

  • Make sure to update secret token: cp ./conf/envDefault.js to ./conf/envLocal.js.
  • Install dependencies: npm install
  • Check there are no broken tests: npm test
  • Run elasticsearch
  • Run server: node ./server.js
  • Run search daemon: node ./bin/search-daemon.js
  • Run mailer daemon: node ./bin/mailer-daemon.js
  • Run rss daemon: node ./bin/rss-daemon.js 1 (1 is a number of background workers)

Assets

This application uses AMD/RequireJS to separate files to controllers, routers, models and templates. To bundle all of them to a single bundle you need to install RequireJS in your system and then run: r.js -o build.js. This will build scripts and put them to ./dist folder after this you need to copy ./dist/main.js and ./dist/common.js to ./public/js.

For any additional options feel free to look into build.js file. By default it generates two files: common.js which includes all libraries like emberjs, handlebars, etc and main.js which is custom pepyatka application.

Nginx

Setup nginx as a proxy server:

upstream app_pepyatka {
    server 127.0.0.1:3000;
}

server {
    listen 0.0.0.0:80;
    server_name pepyatka.com pepyatka;
    access_log /var/log/nginx/pepyatka.log;

    gzip on;
    gzip_comp_level 6;
    gzip_vary on;
    gzip_min_length  1000;
    gzip_proxied any;
    gzip_buffers 16 8k;

    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    location ~ ^/(images/|img/|javascript/|js/|css/|stylesheets/|flash/|media/|static/|files/\
|robots.txt|humans.txt|favicon.ico) {
      root /var/www/pepyatka/public;
      access_log off;
      expires max;
    }

    # disable logging for some `common` files
    # Disable logging for favicon
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    # Disable logging for robots.txt
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location / {
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";

      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;

      proxy_pass http://app_pepyatka/;
      proxy_redirect off;
    }
}

Clone this wiki locally