syxolk / euro2024

Euro 2024: Betting with your friends
https://www.wetten2024.de
54 stars 22 forks source link

future updates #8

Closed Vijay-1979 closed 8 years ago

Vijay-1979 commented 8 years ago

Hi. Great code. I was wondering if you are going to update it further, when the group matches are finished?

syxolk commented 8 years ago

Sure, I will update the group matches shortly after their results are online. Then, you will get points according to your bets.

Vijay-1979 commented 8 years ago

Great. But we have very old server, so it can´t run node.js Is there any other way to use this?

  1. mai 2016 kl. 14.36 skrev Hans notifications@github.com<mailto:notifications@github.com>:

Sure, I will update the group matches shortly after their results are online. Then. you will get points according to your bets.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHubhttps://github.com/syxolk/euro2016/issues/8#issuecomment-221255152

syxolk commented 8 years ago

wetten2016.de is installed on an EC2 instance at Amazon which is free for the first year (including an PostgreSQL Server)

Vijay-1979 commented 8 years ago

Hi. Thanks for the info. I have created a virtual Server on Amazon. But do you have a quick guide to for further prosess on how to install?

  1. mai 2016 kl. 20.03 skrev Hans notifications@github.com<mailto:notifications@github.com>:

wetten2016.dehttp://wetten2016.de is installed on an EC2 instance at Amazonhttp://aws.amazon.com/ which is free for the first year (including an PostgreSQL Server)https://aws.amazon.com/free/faqs/?nc1=h_ls

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHubhttps://github.com/syxolk/euro2016/issues/8#issuecomment-221348684

syxolk commented 8 years ago

You need an EC2 instance (t2.micro is free for the first year; install Ubuntu on it) and an RDS instance with PostgreSQL (which is also free during the first year).

Connect to your EC2 instance via SSH. You need to install NodeJS now. Then follow the instructions on this project's README.

vanshyp commented 8 years ago

wetten2016.de is installed on an EC2 instance at Amazon which is free for the first year (including an PostgreSQL Server)

I installed your app on an EC2 instance with nodejs and postgresql and I get an error on first run (see below). I must be doing something wrong.

_/home/ec2-user/euro2016/routes/login.js:16 where: {email} ^ SyntaxError: Unexpected token } at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (/home/ec2-user/euro2016/node_modules/coffee-script/lib/coffee-script/register.js:45:36) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at module.exports (/home/ec2-user/euro2016/routes/index.js:2:5) at Object. (/home/ec2-user/euro2016/index.js:161:1) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module.load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:935:3

I used an Amazon Linux AMI and did the following:

_sudo yum update sudo yum install -y nginx git sudo yum install -y --enablerepo=epel npm sudo npm install -g forever sudo yum install postgresql postgresql-server postgresql-devel postgresql-contrib postgresql-docs sudo service postgresql initdb sudo service postgresql start sudo -u postgres psql postgres postgres=# \password postgres postgres=# CREATE DATABASE euro2016; postgres=# CREATE USER lukaku password 'origi'; postgres=# GRANT ALL ON DATABASE euro2016 TO lukaku; postgres=# \q git clone https://github.com/syxolk/euro2016.git cd euro2016 npm install sudo npm install -g bower cp template.config.coffee config.coffee nano config.coffee

PostreSQL connection URL

db: 'postgres://lukaku:origi@localhost:5432/euro2016'

node index.js_

Any hints?

syxolk commented 8 years ago

What is your nodejs version? node --version

You need something up to date, since I am using ES2015.

vanshyp commented 8 years ago

node --version v0.10.42

syxolk commented 8 years ago

You need at least 4.x

vanshyp commented 8 years ago

Thanks, I hadn't paid attention to that while installing nodejs. How do I install the latest nodejs on my instance? Disclaimer: not a real programmer, just a hobbyist :)

syxolk commented 8 years ago

Have you tried this: https://nodejs.org/en/download/package-manager/#enterprise-linux-and-fedora

vanshyp commented 8 years ago

Thanks for the hint! I tried that but I got an error while adding the repo:

curl -sL https://rpm.nodesource.com/setup_6.x | bash -

...

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.l5LK0adQWr' error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Permission denied) Error executing command, exiting_

vanshyp commented 8 years ago

Didn't have enough rights so ran as root: sudo -s curl -sL https://rpm.nodesource.com/setup_6.x | bash - yum install -y nodejs

Still no luck as he is complaining about conflicts with files: file /usr/lib/node_modules/npm/bin/npm from install of nodejs-6.2.0-1nodesource.el7.centos.x86_64 conflicts with file from package npm-1.3.6-5.el6.noarch ...

Probably need to remove the previous version first?

vanshyp commented 8 years ago

I managed to update nodejs. From root directory as superuser: yum remove node* curl -sL https://rpm.nodesource.com/setup_6.x | bash - yum install -y nodejs

node -v v6.2.0

Getting another error now. I guess we're making progress :)

node index.js

_/home/ec2-user/euro2016/node_modules/bcrypt/node_modules/bindings/bindings.js:83 throw e ^

Error: Module did not self-register. at Error (native) at Object.Module._extensions..node (module.js:568:18) at Module.load (/home/ec2-user/euro2016/node_modules/coffee-script/lib/coffee-script/register.js:45:36) at tryModuleLoad (module.js:417:12) at Function.Module._load (module.js:409:3) at Module.require (module.js:468:17) at require (internal/module.js:20:19) at bindings (/home/ec2-user/euro2016/node_modules/bcrypt/node_modules/bindings/bindings.js:76:44) at Object. (/home/ec2-user/euro2016/node_modules/bcrypt/bcrypt.js:3:35) at Module._compile (module.js:541:32) at Object.Module._extensions..js (module.js:550:10) at Module.load (/home/ec2-user/euro2016/node_modules/coffee-script/lib/coffee-script/register.js:45:36) at tryModuleLoad (module.js:417:12) at Function.Module._load (module.js:409:3) at Module.require (module.js:468:17) at require (internal/module.js:20:19) at Object. (/home/ec2-user/euro2016/routes/login.js:3:17) at Module._compile (module.js:541:32) at Object.Module._extensions..js (module.js:550:10) at Module.load (/home/ec2-user/euro2016/node_modules/coffee-script/lib/coffee-script/register.js:45:36) at tryModuleLoad (module.js:417:12) at Function.Module._load (module.js:409:3) at Module.require (module.js:468:17) at require (internal/module.js:20:19) at module.exports (/home/ec2-user/euro2016/routes/index.js:2:5) at Object. (/home/ec2-user/euro2016/index.js:161:1) at Module._compile (module.js:541:32) at Object.Module._extensions..js (module.js:550:10) at Module.load (module.js:458:32) at tryModuleLoad (module.js:417:12) at Function.Module.load (module.js:409:3) at Function.Module.runMain (module.js:575:10) at startup (node.js:160:18) at node.js:449:3

syxolk commented 8 years ago

you may need sudo (sry)

vanshyp commented 8 years ago

sudo gets me the same error. How is your setup different from mine? Maybe that could lead us in some direction.

syxolk commented 8 years ago

This bcrypt module gets compiled by npm. You should not get any errors when doing npm install.

Otherwise install gcc/g++

vanshyp commented 8 years ago

How silly of mine: rm -rf node_modules/ npm install

Now postgresql is throwing up errors:

Unhandled rejection SequelizeConnectionError: Ident authentication failed for user "lukaku"
  at /home/ec2-user/euro2016/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:101:20

...

vanshyp commented 8 years ago

I'll take a look at my pg_hba.conf and pg_ident.conf files tomorrow. I think I forgot something during postgresql setup. Thanks for helping out! I'll return tomorrow evening and if everything works out I'll write a howto.

syxolk commented 8 years ago

Either you change the Sequelize connection string to use the ident authentification (I've never tried this) or you change Postgres to allow logins via password from localhost.

Thank you for contributing :smiley:

vanshyp commented 8 years ago

I edited pg_hba.conf at this location: sudo nano /var/lib/pgsql9/data/pg_hba.conf

local all all trust host all 127.0.0.1/32 trust

Restarted postgres afterwards: service postgresql restart

node index.js seems to do its job!

Getting SQL commands from db setup and this message at the end: Visit http://localhost:8080

Can't get the app to show up in my browser though. What am I missing?

syxolk commented 8 years ago

If you are running this on the Amazon EC2 instance you have to open port 8080.

vanshyp commented 8 years ago

It's working! But... the lay-out and images aren't displaying. Everything is in plain html.

Added this rule to AWS Security Groups pane to allow inbound http traffic: HTTP TCP 80 0.0.0.0/0

Edited sysctl.conf to allow port forwarding: sudo nano /etc/sysctl.conf net.ipv4.ip_forward 1 sudo sysctl -p /etc/sysctl.conf

Added necessary rules to iptables: sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080 sudo iptables -A INPUT -p tcp -m tcp --sport 80 -j ACCEPT sudo iptables -A OUTPUT -p tcp -m tcp --dport 80 -j ACCEPT

I'm starting to get the hang of this :)

syxolk commented 8 years ago

Change the setting origin: 'http://localhost:8080' in your config.coffee file to the server's IP address.

syxolk commented 8 years ago

You could also open your browser's developer tools (usually with F12), open the 'Network' tab and look for 404 responses

vanshyp commented 8 years ago

Thanks! I was thinking in that direction and changed that value in config.coffee. Things got a bit messy with conflicting ports so I decided to restart the server.

Now I get these db errors: _Unhandled rejection SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:5432 at /home/ec2-user/euro2016/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:89:20 at . (/home/ec2-user/euro2016/node_modules/pg/lib/client.js:176:5) at emitOne (events.js:96:13) at emit (events.js:188:7) at Socket. (/home/ec2-user/euro2016/node_modules/pg/lib/connection.js:59:10) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at emitErrorNT (net.js:1272:8) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/nexttick.js:98:9)

The db conncetion worked flawlessly before?

vanshyp commented 8 years ago

Nevermind, I forgot to start postgresql again and I had to put in the iptables prerouting again :)

The ip address matches the one in config.coffee but I'm still not getting any lay-out.

I'll do some inspecting in my browser.

vanshyp commented 8 years ago

Upon inspection these files are missing: /bootstrap-social/bootstrap-social.css /bootstrap/dist/css/bootstrap-theme.min.css /bootstrap/dist/css/bootstrap.min.css /bootstrap/dist/js/bootstrap.min.js /font-awesome/css/font-awesome.min.css /jquery/dist/jquery.min.js

How to fix this? So close :)

syxolk commented 8 years ago

Did you do bower install ?

vanshyp commented 8 years ago

I would swear I did, but running bower install again did the trick! Everything seems to be working.

Only issue I have is that nodejs stops when I exit terminal. How can I prevent that?

Login doesn't work either because of recaptcha settings. I'll figure it out tomorrow.

Thanks again!

vanshyp commented 8 years ago

Only issue I have is that nodejs stops when I exit terminal. How can I prevent that?

Discovered forever start. Nice!

vanshyp commented 8 years ago

Login doesn't work either because of recaptcha settings. I'll figure it out tomorrow.

Got recaptcha working.

Mailgun setup tomorrow because I need my own domain name for that. Yeey :)

vanshyp commented 8 years ago

I was able to log in to my site, but I can't bet on matches. The /me page only displays my username and "Score 0, Ranking 1".

syxolk commented 8 years ago

This resets the database and adds all Euro 2016 matches: node tools/populate.js tools/euro2016.json

vanshyp commented 8 years ago

Thanks, that did the trick! Had to register again but that was no biggie :)

Just a few questions:

syxolk commented 8 years ago

Will new matches be added automatically after the group stage?

Nope, I didn't find any good (and free) API for this

When will participants be able to bet on new matches in further stages?

Users can bet on matches at the time when they get created in the datebase.

How do you login as admin or "game master" to exclude users?

There is currently no real exclude functionality. You can just delete the user from the database. This will delete all his bets automatically. But there is an admin panel at example.com/admin. You need to give yourself admin rights before in table User, column admin. Set it to true for your own user id. You can use pgadmin for this.

How does the news section work?

You can publish news in the admin panel. Adding matches or setting match results will automatically generate news.