mike-marcacci / gandhi

The open source, online grant management system.
GNU Affero General Public License v3.0
36 stars 16 forks source link

home page not loading on aws #90

Closed ronna closed 9 years ago

ronna commented 9 years ago

Hi Mike, I installed Gandhi on AWS micro instance the home page is not loading: http://52.25.12.138:3000/ running curl http://localhost:3000 gives the page source

same happens with rethinkdb web interface (tested to see if it was a Gandhi issue)

your assistance in resolving the issue is greatly appreciated.

Note: it works fine on the local machine

ronna commented 9 years ago

Hi Mike,

The rethinkdb admin access issue was due to the bind address, I can now access it.

The Gandhi issues might be due to dependencies issues, package.json might have depencies pinned to lower versions and npm install is fetching higher versions from github.

Affected packages are shown below

ubuntu@ip-172-31-37-107:~/rsc$ npm-check -u ? Choose which packages to update. (Press to select)

Minor Update New backwards-compatible features. ❯◯ chai devDep 3.0.0 ❯ 3.4.0 http://chaijs.com ◯ mocha devDep 2.2.5 ❯ 2.3.3 https://github.com/mochajs/mocha#readme

Major Update Potentially breaking API changes, use caution. ◯ handlebars 3.0.3 ❯ 4.0.3 http://www.handlebarsjs.com/ ◯ bluebird 2.10.2 ❯ 3.0.1 https://github.com/petkaantonov/bluebird ◯ multer 0.1.8 ❯ 1.1.0 https://github.com/expressjs/multer#readme ◯ qs 3.1.0 ❯ 5.2.0 https://github.com/hapijs/qs ◯ redlock 0.4.1 ❯ 1.0.0 https://github.com/mike-marcacci/node-redlock

Non-Semver Versions less than 1.0.0, caution. ◯ passport 0.2.2 ❯ 0.3.0 http://passportjs.org/

Space to select. Enter to start upgrading. Control-C to cancel.

ronna commented 9 years ago

Hi Mike

Please note that, angular-json-human#1.2.1 depends on lodash#~2.4.1 which resolved to lodash#2.4.2 gandhi depends on lodash#3.x.x which resolved to lodash#3.10.1 Resort to using lodash#3.x.x which resolved to lodash#3.10.1

Manually installing the correct versions throws: ubuntu@ip-172-31-37-107:~/rsc$ npm install install lodash@'^2.4.1' gandhi@0.4.3 /home/ubuntu/rsc ├─┬ bower@1.6.5 │ ├─┬ configstore@0.3.2 │ │ └─┬ js-yaml@3.4.3 │ │ └─┬ argparse@1.0.2 │ │ └── lodash@3.10.1 │ └─┬ inquirer@0.10.0 │ └── lodash@3.10.1 ├── install@0.1.8 extraneous ├─┬ ioredis@1.10.0 │ └── lodash@3.10.1 ├── lodash@2.4.2 invalid └─┬ wiredep@2.2.2 └── lodash@2.4.2

Code incompatibilities may occur.

mike-marcacci commented 9 years ago

Hi @ronna!

I'm going to look into this right now, but just to give you a little more to start with, here's a bash script I've used to provision servers to run gandhi. I think in the near future I will probably release a docker image which will be the easiest way to get started!

# User
# ----

useradd -s /bin/bash -d /home/gandhi gandhi
mkdir -p /home/gandhi
chown gandhi:gandhi /home/gandhi

# generate keys
sudo -u gandhi mkdir /home/gandhi/.ssh
sudo -u gandhi ssh-keygen -t rsa -b 4096 -C $(hostname) -f /home/gandhi/.ssh/id_rsa -N ""

# Dependencies
# ------------

# Add Sources
source /etc/lsb-release && echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
wget -qO- http://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
apt-get update

# Install System Deps
apt-get install -y build-essential wget vim git python-pip rethinkdb nginx

# Install Python Deps
pip install rethinkdb

# Install NVM and Node
sudo -u gandhi -H bash -c "
cd ~
touch .bashrc
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.26.1/install.sh | bash
source .bashrc
cp .bashrc .profile
nvm install stable
nvm alias default stable
exit
"

# Configuration
# -------------

# Redis
wget http://download.redis.io/releases/redis-3.0.2.tar.gz
tar xzf redis-3.0.2.tar.gz
cd redis-3.0.2
make
make install
yes '' | utils/install_server.sh
service redis_6379 restart

# RethinkDB
echo "server-name=$(hostname)" > /etc/rethinkdb/instances.d/gandhi.conf
sed -i -r 's/\./_/g' /etc/rethinkdb/instances.d/gandhi.conf
service rethinkdb start

# NGINX
cat << 'EOF' > /etc/nginx/sites-available/gandhi.conf
server {
  listen 0.0.0.0:80;
  access_log /var/log/nginx/yourdomain.log;
  root /www/static;

  client_max_body_size 100M;

  location / {
    try_files $uri @proxy;
    gzip on;
    gzip_types text/css application/javascript application/json text/plain;
  }

  location @proxy {
    internal;
    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_redirect off;
    proxy_pass http://127.0.0.1:3000;
  }
}
EOF
rm /etc/nginx/sites-enabled/default
ln -s /etc/nginx/sites-available/gandhi.conf /etc/nginx/sites-enabled/gandhi.conf
service nginx restart

# Gandhi
# ------

sudo -u gandhi -H bash -c "
cd /home/gandhi
git clone https://github.com/mike-marcacci/gandhi.git
cd gandhi
yes | npm install --production
exit
"

# Upstart Script
cat << 'EOF' > /etc/init/gandhi.conf
description "Gandhi"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [06]

env SCRIPT=/home/gandhi/gandhi/server.js

exec sudo -i -u gandhi node $SCRIPT

respawn
kill timeout 10
EOF

service gandhi start
ronna commented 9 years ago

Hi @mike-marcacci

Thanks for the script, I launched a new instance ran the script and still facing the same issue.

Your assistance will be greatly appreciated

mike-marcacci commented 9 years ago

Hmm, I just spun up a new machine and the script didn't quite get all the way done for me: it stopped at line 100. To finish the rest off, I simply ran (starting as root):

# Make sure the npm dependencies are installed
cd /home/gandhi/gandhi
sudo su gandhi
yes | npm install
exit

then I ran:

# Make sure the upstart script is installed
cat << 'EOF' > /etc/init/gandhi.conf
description "Gandhi"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [06]

env SCRIPT=/home/gandhi/gandhi/server.js

exec sudo -i -u gandhi node $SCRIPT

respawn
kill timeout 10
EOF

and then:

# start gandhi and check its status
service gandhi start
service gandhi status

This got everything running for me with data from the test fixtures. Once it's up, you can log in as any of the users found here. Each user's password is their first name + 1234, so the user mike.marcacci@test.gandhi.io for example, has a password of mike1234.

Hope that helps!

ronna commented 9 years ago

Hi @mike-marcacci

Thank you so much for your time and assistance, the server is now up and running

mike-marcacci commented 9 years ago

Glad you got it working! I'm going to close out this issue, but feel free to create another issue if you encounter more!