From e1f881a3368be7982a39a96072f273d7c0ed0ff1 Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Sun, 24 Apr 2016 14:22:04 -0400 Subject: [PATCH 01/16] added production to ecosystem.json --- ecosystem.json | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ecosystem.json b/ecosystem.json index 8275822f..c98e6a2c 100644 --- a/ecosystem.json +++ b/ecosystem.json @@ -10,11 +10,23 @@ "ref" : "origin/master", "repo" : "git@github.com:whitef0x0/tellform.git", "path" : "/opt/deploy", - "post-deploy" : "npm install && bower install --allow-root && pm2 startOrRestart ecosystem.json --env production", + "post-deploy" : "npm install && bower install && pm2 startOrRestart ecosystem.json --env production", "env" : { "NODE_ENV": "production", "BASE_URL": "stage.tellform.com" } - } - } + }, + "prod" : { + "user" : "polydaic", + "host" : "159.203.33.182", + "ref" : "origin/master", + "repo" : "git@github.com:whitef0x0/tellform.git", + "path" : "/opt/deploy", + "post-deploy" : "npm install && bower install && pm2 startOrRestart ecosystem.json --env production", + "env" : { + "NODE_ENV": "production", + "BASE_URL": "admin.tellform.com" + } + } + } } From 4646fb6f1ecd7dd313caca4bfd0d3f6944573b8b Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Sun, 24 Apr 2016 14:34:19 -0400 Subject: [PATCH 02/16] added google analytics support --- app/views/layout.server.view.html | 10 ++++++++++ config/env/all.js | 3 ++- config/express.js | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/views/layout.server.view.html b/app/views/layout.server.view.html index d622bde8..92cafda9 100755 --- a/app/views/layout.server.view.html +++ b/app/views/layout.server.view.html @@ -114,7 +114,17 @@

Yes, upgrade my browser!

+ + + diff --git a/config/env/all.js b/config/env/all.js index c0339f48..41891bbd 100755 --- a/config/env/all.js +++ b/config/env/all.js @@ -2,6 +2,7 @@ module.exports = { app: { + google_analytics_id: process.env.GOOGLE_ANALYTICS_ID || ''; title: 'TellForm', description: 'Opensource form builder alternative to TypeForm', keywords: 'typeform, pdfs, forms, opensource, formbuilder, google forms, nodejs', @@ -18,7 +19,7 @@ module.exports = { }, //Sentry DSN Client Key - DSN: 'http://db01e03015ce48e2b68240ea8254b17c:5d878e9bb6c6488fbb70fb81295ee700@sentry.polydaic.com/1', + //DSN: // The secret should be set to a non-guessable string that // is used to compute a session hash diff --git a/config/express.js b/config/express.js index 301a48b6..7a341190 100755 --- a/config/express.js +++ b/config/express.js @@ -38,10 +38,10 @@ module.exports = function(db) { }); // Setting application local variables + app.locals.google_analytics_id = config.app.oogle_analytics_id; app.locals.title = config.app.title; app.locals.description = config.app.description; app.locals.keywords = config.app.keywords; - app.locals.facebookAppId = config.facebook.clientID; app.locals.bowerJSFiles = config.getBowerJSAssets(); app.locals.bowerCssFiles = config.getBowerCSSAssets(); From f4fde131d757afc2a43671a844f1e1a7ecfca47f Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Sun, 24 Apr 2016 14:35:42 -0400 Subject: [PATCH 03/16] fixed formatting bug in config/env/all.js --- config/env/all.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/env/all.js b/config/env/all.js index 41891bbd..b88a955b 100755 --- a/config/env/all.js +++ b/config/env/all.js @@ -2,7 +2,7 @@ module.exports = { app: { - google_analytics_id: process.env.GOOGLE_ANALYTICS_ID || ''; + google_analytics_id: process.env.GOOGLE_ANALYTICS_ID || '', title: 'TellForm', description: 'Opensource form builder alternative to TypeForm', keywords: 'typeform, pdfs, forms, opensource, formbuilder, google forms, nodejs', From 1ef5a3e3e17f9d7234388d21e491972d0f6b244b Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Sun, 24 Apr 2016 14:41:27 -0400 Subject: [PATCH 04/16] fixed google analytics app.local --- config/express.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/express.js b/config/express.js index 7a341190..878450a3 100755 --- a/config/express.js +++ b/config/express.js @@ -38,7 +38,7 @@ module.exports = function(db) { }); // Setting application local variables - app.locals.google_analytics_id = config.app.oogle_analytics_id; + app.locals.google_analytics_id = config.app.google_analytics_id; app.locals.title = config.app.title; app.locals.description = config.app.description; app.locals.keywords = config.app.keywords; From 3c063062a5216875401ca3c0b5fd5b91f53ecab1 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 24 Apr 2016 22:29:11 +0300 Subject: [PATCH 05/16] link db from web container --- docker-compose.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2aa0d8e2..c2795c58 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,9 +3,9 @@ version: '2' services: db: image: mongo:3.2 - command: ['bash', '-c', 'mongod --storageEngine wiredTiger'] #['mongod', '--storageEngine', 'wiredTiger'] +# command: ['bash', '-c', 'mongod --storageEngine wiredTiger'] #['mongod', '--storageEngine', 'wiredTiger'] volumes: - - mongo-data-wt:/data/db + - ./mongo-data-wt:/data/db #- /tmp/etc:/etc networks: - back-tier @@ -19,6 +19,8 @@ services: - "35729:35729" networks: - back-tier + links: + - db volumes: mongo-data-wt: driver: local From 18c8ef605b7aa8f6fe45138b6bafc27fca092e96 Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Sun, 24 Apr 2016 14:10:53 -0700 Subject: [PATCH 06/16] Update README.md --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9b2b4f98..5ef8449b 100755 --- a/README.md +++ b/README.md @@ -55,10 +55,13 @@ $ grunt build Create your .env file. It should look like this ``` -MAILER_EMAIL_ID=example@test.com +GOOGLE_ANALYTICS_ID=yourGAID +PRERENDER_TOKEN=yourPrerender.ioToken +COVERALLS_REPO_TOKEN=yourCoveralls.ioToken +MAILER_EMAIL_ID=SMTP_Injection MAILER_FROM=noreply@yourdomain.com -MAILER_PASSWORD=yourmandrillapikey -MAILER_SERVICE_PROVIDER=Mandrill +MAILER_PASSWORD=your_sparkpost_apikey +MAILER_SERVICE_PROVIDER=SparkPost BASE_URL=yourdomain.com ``` From 1b38aae75b2db22bd46b81d8f0235a572c32794f Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Sun, 24 Apr 2016 14:11:40 -0700 Subject: [PATCH 07/16] Bumped version number to 1.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4ebe5b22..1b8b6b78 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "TellForm", "description": "Opensource alternative to TypeForm", - "version": "1.2.1", + "version": "1.3.0", "homepage": "https://github.com/whitef0x0/tellform", "authors": [ "David Baldwynn (http://baldwynn.me)" From 621e1485dbe6a0937853529f623868a47cbb9ded Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Sun, 24 Apr 2016 14:19:44 -0700 Subject: [PATCH 08/16] Update setup_sentry_server.md --- docs/setup_sentry_server.md | 103 +++++++++++++++++------------------- 1 file changed, 50 insertions(+), 53 deletions(-) diff --git a/docs/setup_sentry_server.md b/docs/setup_sentry_server.md index 1680820e..8779d495 100644 --- a/docs/setup_sentry_server.md +++ b/docs/setup_sentry_server.md @@ -1,13 +1,10 @@ -Installing Sentry Server ------------------------- +#Installing Sentry Server -TellForm is an opensource *form builder* that can create stunning forms from PDFs or from scratch - -## Before You Begin +### Before You Begin Make sure you understand what sentry server does. You can view documentation for sentry server [here](https://sentry.readthedocs.org/). This document was written for a server running *Ubuntu 14.04 LTS server* (we used Azure). -## Prerequisites +### Prerequisites Make sure you have these installed: * apt-get * python2.7 @@ -15,32 +12,32 @@ Make sure you have these installed: -## Installation Steps +### Installation Steps 1. Add non-root user. -``` -sudo adduser sentry -sudo adduser sentry sudo -``` + ``` + sudo adduser sentry + sudo adduser sentry sudo + ``` 2. Update all apt-get packages -``` -sudo apt-get update -sudo apt-get dist-upgrade -sudo apt-get autoremove -sudo apt-get install libxml2-dev libxslt1-dev libffi-dev -sudo reboot -``` + ``` + sudo apt-get update + sudo apt-get dist-upgrade + sudo apt-get autoremove + sudo apt-get install libxml2-dev libxslt1-dev libffi-dev + sudo reboot + ``` 3. Install easy_install and pip -``` -wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python -sudo easy_install pip -``` + ``` + wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python + sudo easy_install pip + ``` 4. Install virtualenv and virtualenvwrapper -``` -sudo pip install virtualenv -``` + ``` + sudo pip install virtualenv + ``` 5. Install Sentry and Setup ``` @@ -56,38 +53,38 @@ pip install -U sentry[postgres] ``` 6. Install postgresql -``` -# install postgres -sudo apt-get install postgresql postgresql-contrib libpq-dev - -# install postgres adminpack -sudo -u postgres psql -CREATE EXTENSION "adminpack"; -\q -``` + ``` + # install postgres + sudo apt-get install postgresql postgresql-contrib libpq-dev + + # install postgres adminpack + sudo -u postgres psql + CREATE EXTENSION "adminpack"; + \q + ``` 7. Setup postgresql DB -``` -# change postgres password & create database -sudo passwd postgres -sudo su - postgres -psql -d template1 -c "ALTER USER postgres WITH PASSWORD 'changeme';" -createdb sentry -createuser sentry_user --pwprompt -psql -d template1 -U postgres -GRANT ALL PRIVILEGES ON DATABASE sentry to sentry_user; -\q -exit -``` + ``` + # change postgres password & create database + sudo passwd postgres + sudo su - postgres + psql -d template1 -c "ALTER USER postgres WITH PASSWORD 'changeme';" + createdb sentry + createuser sentry_user --pwprompt + psql -d template1 -U postgres + GRANT ALL PRIVILEGES ON DATABASE sentry to sentry_user; + \q + exit + ``` 8. Setup Sentry Configuration -``` -# initialize conf file -sentry init - -#edit sentry configuration -vim ~/.sentry/sentry.conf.py -``` + ``` + # initialize conf file + sentry init + + #edit sentry configuration + vim ~/.sentry/sentry.conf.py + ``` The following are the contents of my sentry.conf.py file (replace name, user and password with your that of your DB) From b9db4d28d0ebe85eef2f5044d0c64d9650a74e2c Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Sun, 24 Apr 2016 14:23:20 -0700 Subject: [PATCH 09/16] Added pip install lmxl in sentry setup doc --- docs/setup_sentry_server.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/setup_sentry_server.md b/docs/setup_sentry_server.md index 8779d495..54bdaf0c 100644 --- a/docs/setup_sentry_server.md +++ b/docs/setup_sentry_server.md @@ -24,7 +24,7 @@ Make sure you have these installed: sudo apt-get update sudo apt-get dist-upgrade sudo apt-get autoremove - sudo apt-get install libxml2-dev libxslt1-dev libffi-dev + sudo apt-get install libxml2-dev libxslt1-dev libffi-dev libpq-dev python-dev sudo reboot ``` @@ -34,9 +34,10 @@ Make sure you have these installed: sudo easy_install pip ``` -4. Install virtualenv and virtualenvwrapper +4. Install virtualenv and lmxl ``` sudo pip install virtualenv + sudo pip install lxml ``` 5. Install Sentry and Setup From 3e1126e7e5ca874ca294c59736d36df93e8a638b Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Sun, 24 Apr 2016 14:24:56 -0700 Subject: [PATCH 10/16] Fixed numbering problems in setup_sentry_server.md --- docs/setup_sentry_server.md | 314 ++++++++++++++++++------------------ 1 file changed, 157 insertions(+), 157 deletions(-) diff --git a/docs/setup_sentry_server.md b/docs/setup_sentry_server.md index 54bdaf0c..0b85ffc5 100644 --- a/docs/setup_sentry_server.md +++ b/docs/setup_sentry_server.md @@ -41,17 +41,17 @@ Make sure you have these installed: ``` 5. Install Sentry and Setup -``` -# make server directory -mkdir ~/SentryServer; cd ~/SentryServer; -# make virtualenv -virtualenv ./ -#activate virtualenv -source ./bin/activate - -# install sentry and its postgresql dependencies -pip install -U sentry[postgres] -``` + ``` + # make server directory + mkdir ~/SentryServer; cd ~/SentryServer; + # make virtualenv + virtualenv ./ + #activate virtualenv + source ./bin/activate + + # install sentry and its postgresql dependencies + pip install -U sentry[postgres] + ``` 6. Install postgresql ``` @@ -87,162 +87,162 @@ pip install -U sentry[postgres] vim ~/.sentry/sentry.conf.py ``` -The following are the contents of my sentry.conf.py file (replace name, user and password with your that of your DB) - -``` -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'sentry', - 'USER': 'sentry_user', - 'PASSWORD': 'your_password', - 'HOST': 'localhost', - } -} -# No trailing slash! -SENTRY_URL_PREFIX = 'http://sentry.example.com' - -SENTRY_WEB_HOST = '0.0.0.0' -SENTRY_WEB_PORT = 9000 -SENTRY_WEB_OPTIONS = { - 'workers': 3, # the number of gunicorn workers - 'secure_scheme_headers': {'X-FORWARDED-PROTO': 'https'}, # detect HTTPS mode from X-Forwarded-Proto header -} - -#CONFIGURE REDIS -SENTRY_REDIS_OPTIONS = { - 'hosts': { - 0: { - 'host': '127.0.0.1', - 'port': 6379, - 'timeout': 3, - #'password': 'redis auth password' - } - } -} - -#CONFIGURE OUTGOING MAIL -EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' -EMAIL_USE_TLS = True -EMAIL_HOST = 'smtp.gmail.com' -EMAIL_PORT = 587 -EMAIL_HOST_USER = 'your_gmail_username@gmail.com' -EMAIL_HOST_PASSWORD = 'your_gmail_password' -DEFAULT_FROM_EMAIL = 'testing@testing.com -``` + The following are the contents of my sentry.conf.py file (replace name, user and password with your that of your DB) + + ``` + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': 'sentry', + 'USER': 'sentry_user', + 'PASSWORD': 'your_password', + 'HOST': 'localhost', + } + } + # No trailing slash! + SENTRY_URL_PREFIX = 'http://sentry.example.com' + + SENTRY_WEB_HOST = '0.0.0.0' + SENTRY_WEB_PORT = 9000 + SENTRY_WEB_OPTIONS = { + 'workers': 3, # the number of gunicorn workers + 'secure_scheme_headers': {'X-FORWARDED-PROTO': 'https'}, # detect HTTPS mode from X-Forwarded-Proto header + } + + #CONFIGURE REDIS + SENTRY_REDIS_OPTIONS = { + 'hosts': { + 0: { + 'host': '127.0.0.1', + 'port': 6379, + 'timeout': 3, + #'password': 'redis auth password' + } + } + } + + #CONFIGURE OUTGOING MAIL + EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' + EMAIL_USE_TLS = True + EMAIL_HOST = 'smtp.gmail.com' + EMAIL_PORT = 587 + EMAIL_HOST_USER = 'your_gmail_username@gmail.com' + EMAIL_HOST_PASSWORD = 'your_gmail_password' + DEFAULT_FROM_EMAIL = 'testing@testing.com + ``` 9. Setup Database and Start Sentry -``` -#install and run redis-server -wget http://download.redis.io/releases/redis-stable.tar.gz -tar xzf redis-stable.tar.gz -cd redis-stable -make -make test -sudo make install -cd utils -sudo ./install_server.sh - -#Go back to app directory -cd ~/SentryServer -sudo service redis_6379 start - -# set up databse -sentry upgrade - -# let's try it out! -sentry start -``` + ``` + #install and run redis-server + wget http://download.redis.io/releases/redis-stable.tar.gz + tar xzf redis-stable.tar.gz + cd redis-stable + make + make test + sudo make install + cd utils + sudo ./install_server.sh + + #Go back to app directory + cd ~/SentryServer + sudo service redis_6379 start + + # set up databse + sentry upgrade + + # let's try it out! + sentry start + ``` 10. Install nginx -``` -# install nginx -sudo apt-get install nginx - -# remove the default symbolic link -sudo rm /etc/nginx/sites-enabled/default - -# create a new blank config, and make a symlink to it -sudo touch /etc/nginx/sites-available/sentry -cd /etc/nginx/sites-enabled -sudo ln -s ../sites-available/sentry - -# edit the nginx configuration file -sudo vim /etc/nginx/sites-available/sentry -``` -*Here are the contents of my nginx file:* -``` -server { - # listen on port 80 - listen 80; - - # for requests to these domains - server_name yourdomain.com www.yourdomain.com; - - # keep logs in these files - access_log /var/log/nginx/sentry.access.log; - error_log /var/log/nginx/sentry.error.log; - - # You need this to allow users to upload large files - # See http://wiki.nginx.org/HttpCoreModule#client_max_body_size - # I'm not sure where it goes, so I put it in twice. It works. - client_max_body_size 0; - - location / { - proxy_pass http://localhost:9000; - proxy_redirect off; - - proxy_read_timeout 5m; - - # make sure these HTTP headers are set properly - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } -} -``` + ``` + # install nginx + sudo apt-get install nginx + + # remove the default symbolic link + sudo rm /etc/nginx/sites-enabled/default + + # create a new blank config, and make a symlink to it + sudo touch /etc/nginx/sites-available/sentry + cd /etc/nginx/sites-enabled + sudo ln -s ../sites-available/sentry + + # edit the nginx configuration file + sudo vim /etc/nginx/sites-available/sentry + ``` + *Here are the contents of my nginx file:* + ``` + server { + # listen on port 80 + listen 80; + + # for requests to these domains + server_name yourdomain.com www.yourdomain.com; + + # keep logs in these files + access_log /var/log/nginx/sentry.access.log; + error_log /var/log/nginx/sentry.error.log; + + # You need this to allow users to upload large files + # See http://wiki.nginx.org/HttpCoreModule#client_max_body_size + # I'm not sure where it goes, so I put it in twice. It works. + client_max_body_size 0; + + location / { + proxy_pass http://localhost:9000; + proxy_redirect off; + + proxy_read_timeout 5m; + + # make sure these HTTP headers are set properly + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + } + ``` 11. Start the worker processes -``` -# restart nginx -sudo service nginx restart - -#start sentry -sentry celery worker -B -``` + ``` + # restart nginx + sudo service nginx restart + + #start sentry + sentry celery worker -B + ``` 12. Install and Configure supervisord -``` -pip install supervisord -sudo echo_supervisord_conf > ~/SentryServer/etc/supervisord.conf - -#Edit yuour supervisord Config -vim /etc/supervisord.conf -``` + ``` + pip install supervisord + sudo echo_supervisord_conf > ~/SentryServer/etc/supervisord.conf + + #Edit yuour supervisord Config + vim /etc/supervisord.conf + ``` Configuration file should look like this -``` -[program:sentry-web] -directory=~/SentryServer/ -command=~/SentryServer/bin/sentry start -autostart=true -autorestart=true -redirect_stderr=true -stdout_logfile=syslog -stderr_logfile=syslog - -[program:sentry-worker] -directory=~/SentryServer/ -command=~/SentryServer/bin/sentry celery worker -B -autostart=true -autorestart=true -redirect_stderr=true -stdout_logfile=syslog -stderr_logfile=syslog -``` + ``` + [program:sentry-web] + directory=~/SentryServer/ + command=~/SentryServer/bin/sentry start + autostart=true + autorestart=true + redirect_stderr=true + stdout_logfile=syslog + stderr_logfile=syslog + + [program:sentry-worker] + directory=~/SentryServer/ + command=~/SentryServer/bin/sentry celery worker -B + autostart=true + autorestart=true + redirect_stderr=true + stdout_logfile=syslog + stderr_logfile=syslog + ``` 13. Run Server (with supervisord) -``` -supervisord -``` + ``` + supervisord + ``` From e03e13b66149bb42a9da33a4855b637a86ceb634 Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Sun, 24 Apr 2016 15:46:04 -0700 Subject: [PATCH 11/16] Update setup_sentry_server.md --- docs/setup_sentry_server.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/setup_sentry_server.md b/docs/setup_sentry_server.md index 0b85ffc5..7b864791 100644 --- a/docs/setup_sentry_server.md +++ b/docs/setup_sentry_server.md @@ -206,7 +206,8 @@ Make sure you have these installed: 11. Start the worker processes ``` # restart nginx - sudo service nginx restart + sudo nginx -t + sudo service nginx reload #start sentry sentry celery worker -B From d61b6987d61c8e7e645a1a71a14baf8b2b4013af Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Sun, 24 Apr 2016 19:14:31 -0400 Subject: [PATCH 12/16] re-enabled raven --- app/views/layout.server.view.html | 16 ++++++++-------- config/env/all.js | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/layout.server.view.html b/app/views/layout.server.view.html index 92cafda9..48aaaeea 100755 --- a/app/views/layout.server.view.html +++ b/app/views/layout.server.view.html @@ -96,14 +96,14 @@ {% endif %}