HabitRPG / habitica

A habit tracker app which treats your goals like a Role Playing Game.
https://habitica.com
Other
11.82k stars 4.05k forks source link

Failed to run server.js #791

Closed dadadel closed 11 years ago

dadadel commented 11 years ago

Hi,

I'm trying to install habitrpg on a Raspberry pi. I followed the Running Locally wiki page but I encounter an issue running the server.

On Linux Raspbian Wheezy I've compiled: Raspie-MongoDB (MongoDB shell version 2.1.1) node v0.8.22 then cloned and installed habitrpg I kept the initial config.json.example renamed into config.js

running:

node server.js

The program prints nothing until about 45 seconds, then appears:

info - socket.io started

And after less then 1 minute, the program prints:

Expressions in require() statements: require('./lang/' + key)

And after few seconds stops running with message:

Bus error (In fact: "Erreur de bus" in french)

nmap shows that the port 3000, initially closed, is opened during a time before the program stops. Using a web navigator on http://localhost:3000, will send request and wait a response until the program fails.

Any idea about how to investigate further that problem?

lefnire commented 11 years ago

Can you try this with the latest push to the develop branch? Does node.js work normally on Raspberry Pi? How about DerbyJS?

On Monday, April 8, 2013, dadadel wrote:

Hi,

I'm trying to install habitrpg on a Raspberry pi. I followed the Running Locally wiki page but I encounter an issue running the server.

-

Context: On Linux Raspbian Wheezy I've compiled: Raspie-MongoDB (MongoDB shell version 2.1.1) node v0.8.22 then cloned and installed habitrpg I kept the initial config.json.example renamed into config.js

Issue: running:

node server.js

The program prints nothing until about 45 seconds, the appears:

info - socket.io started

And after less then 1 minute, the program prints:

Expressions in require() statements: require('./lang/' + key)

And after few seconds stops running with message:

Bus error (In fact: "Erreur de bus" in french)

nmap shows that the 3000 port, initially closed, is opened during a time before the program stops. Using a web navigator on http://localhost:3000, will send request and wait a response until the program fails.

Any idea about how to investigate further that problem?

— Reply to this email directly or view it on GitHubhttps://github.com/lefnire/habitrpg/issues/791 .

dadadel commented 11 years ago

Thanks for your reply.

I pulled the develop branch and there was a difference.

The server.js run without stopping :). The web browser replies "Cannot GET /". The server provides errors and in particular one message concerning a bad identity for gmail account. So I created an account and set the config.json with login/pwd.

After that, there was still an error related to mongodb "Error connecting to database", the server again continue to run. The web browser still replies "Cannot GET /".

I've fixed the problem that was concerning access permissions. But after that I am back to the first issue, with server.js stopping after 2 minutes with the same behaviour: info - socket.io started Expressions in require() statements: require('./lang/' + key) Erreur du bus

PS: the web browser that I use for testing is links2 (ascii browser) that doesn't provide JavaScript. Of course when HabitRPG will work I'll use a graphical browser!

lefnire commented 11 years ago

The "Cannot GET /" thing is fine, you just need to refresh the page again after that. The Gmail thing is fine too, it's just trying to email you the error it just showed you https://github.com/lefnire/habitrpg/pull/632 .

Is mongo configured and running properly? Everything looks fine to me except Erreur du bus , is that a seg fault? Also, you're definitely not going to be able to get it working with links2, lol - it doesn't even work in IE 9. Derby is a pure javascript end-to-end framework, so disabling or even limiting javascript on the browser and the app won't work. If you want terminal access you'll need to use hrpg or habitrpg-ncurses (http://community.habitrpg.com/extensions)

dadadel commented 11 years ago

Mongo seems to work properly. Is there something special to do to configure it? Shall I create manually a database?

It seems that "Erreur du bus" means "core dump"

lefnire commented 11 years ago

Do mongo habitrpg and you get a console just fine? So after the core dump, it crashes the server and you can't load localhost:3000?

On Wed, Apr 10, 2013 at 11:58 AM, dadadel notifications@github.com wrote:

Mongo seems to work properly. Is there something special to do to configure it? Shall I create manually a database?

It seems that "Erreur du bus" means "core dump"

— Reply to this email directly or view it on GitHubhttps://github.com/lefnire/habitrpg/issues/791#issuecomment-16183521 .

dadadel commented 11 years ago

'mongo habitrpg' open a console, then 'show dbs' outputs: habitrpg (empty) local (empty)

Yes, when the server crashes it is impossible to load localhost:3000. And it crashes before having any response from localhost:3000

The pity is that there is no debug information to investigate where does it crash!

HLFH commented 11 years ago

Same error now on Hackberry (running ArchLinux ARM) after a downgrade to Nodejs v0.8.25 with HabitRPG develop branch. So I will try again HabitRPG challenges-and-0.5 branch with Nodejs v0.10.12-1.

With Nodejs v0.8.25 :

yaourt -S python2 python2-virtualenv
virtualenv2 env
source env/bin/activate 
git clone -b v0.8.25 https://github.com/joyent/node.git
cd node/
export GYP_DEFINES="armv7=1"

export CCFLAGS="-march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16 -O2 -pipe -fstack-protector --param=ssp-buffer-size=4" 
export CXXFLAGS="-march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16 -O2 -pipe -fstack-protector --param=ssp-buffer-size=4" 

./configure --shared-openssl --shared-openssl-includes=/usr/include/openssl --shared-openssl-libpath=/usr/lib--shared-zlib --shared-zlib-includes=/usr/include --shared-zlib-libpath=/usr/lib 

make
su -c 'make install'

With Nodejs v0.10.12-1

yaourt -S python2 python2-virtualenv
virtualenv2 env
source env/bin/activate 
yaourt -S nodejs
HLFH commented 11 years ago

Hum maybe relative to this patch : https://github.com/joyent/node/commit/90efdb3a5b7eecb23d78cffee24c3181280efa56, but I prefer the second way, it's easier.

lefnire commented 11 years ago

It looks like you're having some environment issues actually, rather than code setup problems - but just in case, I made a video for you (and anyone else that would benefit) for installing the challenges-and-0.5 branch locally:

https://www.youtube.com/watch?v=MJjo6m_sIqE

HLFH commented 11 years ago

Thanks for the video. I have a bus error (core dumped) so it's a segmentation fault error...after :

npm install -g coffee-script 
coffee install.coffee

So it does not work when I want to register.

With this error, I have this explanation :

 Please ensure that you set the default write concern for the database by setting    =
=   one of the options                                                                 =
=                                                                                      =
=     w: (value of > -1 or the string 'majority'), where < 1 means                     =
=        no write acknowlegement                                                       =
=     journal: true/false, wait for flush to journal before acknowlegement             =
=     fsync: true/false, wait for flush to file system before acknowlegement           =
=                                                                                      =
=  For backward compatibility safe is still supported and                              =
=   allows values of [true | false | {j:true} | {w:n, wtimeout:n} | {fsync:true}]      =
=   the default value is false which means the driver receives does not                =
=   return the information of the success/error of the insert/update/remove            =
=                                                                                      =
=   ex: new Db(new Server('localhost', 27017), {safe:false})                           =
=                                                                                      =
=   http://www.mongodb.org/display/DOCS/getLastError+Command                           =
=                                                                                      =
=  The default of no acknowlegement will change in the very near future                =
=                                                                                      =
=  This message will disappear when the default safe is set on the driver Db     
lefnire commented 11 years ago

definitely platform issues then. Give npm uninstall -g coffee-script && npm install -g coffee-script-redux a shot just for shits & giggles. If that works, swap out coffee-script in habit's package.json with coffee-script-redux

HLFH commented 11 years ago

To give you a real answer :

[root@archlinux-server habitrpg]#npm uninstall -g coffee-script && npm install -g coffee-script-redux
[root@archlinux-server habitrpg]#coffee install.coffee 
========================================================================================
=  Please ensure that you set the default write concern for the database by setting    =
=   one of the options                                                                 =
=                                                                                      =
=     w: (value of > -1 or the string 'majority'), where < 1 means                     =
=        no write acknowlegement                                                       =
=     journal: true/false, wait for flush to journal before acknowlegement             =
=     fsync: true/false, wait for flush to file system before acknowlegement           =
=                                                                                      =
=  For backward compatibility safe is still supported and                              =
=   allows values of [true | false | {j:true} | {w:n, wtimeout:n} | {fsync:true}]      =
=   the default value is false which means the driver receives does not                =
=   return the information of the success/error of the insert/update/remove            =
=                                                                                      =
=   ex: new Db(new Server('localhost', 27017), {safe:false})                           =
=                                                                                      =
=   http://www.mongodb.org/display/DOCS/getLastError+Command                           =
=                                                                                      =
=  The default of no acknowlegement will change in the very near future                =
=                                                                                      =
=  This message will disappear when the default safe is set on the driver Db           =
========================================================================================
Bus error (core dumped)

So, can I do that manually...? And how ?

For info, I reinstalled all my Hackberry server (ARM Architecture), and solved a RAM issue. And there is always this bug.

And for instant, MongoDB is not very nice for ARM architecture : https://jira.mongodb.org/browse/SERVER-1811, so...

HLFH commented 11 years ago

If I replace by : db = mongo.db "#{mongo_host}:#{mongo_port}/#{mongo_db}?auto_reconnect", safe: true, strict: false

I have now :

[root@archlinux-server habitrpg]# coffee install.coffee 
Bus error (core dumped)
HLFH commented 11 years ago

Solved ! You can close this topic.

I reinstalled everything, solved a RAM issue (https://www.miniand.com/forums/forums/development--3/topics/ram-size-issue-512mb-not-1-gb-for-nand-image-u-boot-bin-patwood), switched definitely from challenges-and-0.5 to develop branch with an old Node 0.8.17 and here are the details :

Redis install

yaourt -S scons boost redis 
vim /etc/redis.conf
Replace : 
appendonly yes 
appendfsync always
:wq!

vim /etc/sysctl.conf 
Add :
vm.overcommit_memory=1
:wq!

systemctl enable redis
systemctl start redis

Get Mongodb with ARM support :

-Compilation needed, with a discontinued fork

git clone https://github.com/skrabban/mongo-nonx86
cd mongo-nonx86
for i in `grep -lr TIME_UTC`; do
sed -i s/TIME_UTC/TIME_UTC_/ $i;
done
scons
sudo scons --prefix=/root/mongodb install
PATH=$PATH:/root/mongodb/bin/
export PATH
rm -rf mongo-nonx86

-Binary package related to this topic : https://jira.mongodb.org/browse/SERVER-1811

wget https://s3.amazonaws.com/wtfuzz/mongo-arm/mongodb-linux-armv7l-2.4.1.tgz
tar xvf mongodb-linux-armv7l-2.4.1.tgz
mv mongodb-linux-armv7l-2.4.1 mongodb
PATH=$PATH:/root/mongodb/bin/
export PATH
rm -rf mongodb-linux-armv7l-2.4.1.tgz

Create database and launch Mongodb :

mkdir /var/lib/mongodb 
chown -R root:root /var/lib/mongodb
mongod --dbpath /var/lib/mongodb

NodeJS & HabitRPG Install

yaourt -S python2 python2-virtualenv
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
source ~/.nvm/nvm.sh
virtualenv2 env
source env/bin/activate
nvm install 0.8.17
nvm use 0.8.17
Make sure mongo running > mongo habitrpg and exit
Make sure redis running > redis-cli and exit
cd /var/www/
git clone --recursive -b develop https://github.com/lefnire/habitrpg.git
cd habitrpg
npm install
cp config.json.example config.json
vim config.json
{
    "PORT":3000,
    "IP":"192.168.1.23",
    "BASE_URL":"http://192.168.1.23:3000",
    "FACEBOOK_KEY":"my_fbkey",
    "FACEBOOK_SECRET":"my_fbsecret",
    "NODE_DB_URI":"mongodb://192.168.1.23/habitrpg",
    "NODE_ENV":"development",
    "SESSION_SECRET":"my_sessionsecret",
    "SMTP_USER":"my_email",
    "SMTP_PASS":"my_emailpwd",
    "SMTP_SERVICE":"Gmail",
    "STRIPE_API_KEY":"my_stripe_apikey",
    "STRIPE_PUB_KEY":"my_stripe_pubkey"
}
:wq! 
node server.js
lefnire commented 11 years ago

glad you got things working! so you're back on the develop branch then? hope so, don't want to send you down a rabbit hole - we had to abandon the 0.5 upgrade (details here). Though if you simply want to run the project on your local machine for your own purposes, running the upgrade branch should be just fine.

Also, if you are on develop, you no longer need Redis installed - was only a requirement for Derby 0.5. Anyway, sorry for all your troubles getting things running. Shall I close this issue indeed?

HLFH commented 11 years ago

Yes :

git branch -vv
* develop 5017be0 [origin/develop] API: remove all private paths from server ops, they're unecessary and might be causing issues

You can close this issue related to ARM Single-board computers. Thanks for everything and your amazing work ! I'm just trying now to set up NodeJS and HabitRPG with Forever.js and Systemd (https://github.com/lefnire/habitrpg/issues/1270) but I think I will solve it quickly

lefnire commented 11 years ago