MeteorJS on Raspberry Linux ARM

Probably in the future we'll have cluster of autobalanced low power arm servers, in the meanwhile we have the Raspberry Pi, which is already a quite popular computer to be a media center or an hackable/silent/small/cheap home server.

The Meteor framework is quite easy to install on a mainstran architecture x86_64 with GNU/Linux or OSX as operative system,.. unfortunatly it is a bit more complicated on Windows, FreeBSD or Linux ARM.

Let's see some issues you could find installing MeteorJS on Linux ARM.

Raspbian Debian or Archlinux ARM?

I like Debian/Ubuntu stability and PPA repository for bleding-edge software, but on ARM I chose Archlinux ARM for its systemd and MongoDB 2.6.1 out-of-the-box support. Yes, currently only Arch packages MongoDB on ARM probably because there are some open issues mainstream.

sudo pacman -Sy nodejs mongodb python2 make gcc

Python2 and the gcc are there because you need to recompile some x86_64 native stuff bundled with meteor_apps to ARM/32-bit architecture.

Where is NodeJS 0.10.28 for Linux ARM?

Arch packages Node 0.10.30-1, MeteorJS needs Node 0.10.29, but Node 0.10.29 binaries are missing on ARM. The official NodeJS site ship node-v0.10.28-linux-arm-pi.tar.gz, so what to do?

Install the distro nodejs package from the distro and use "n" to switch to another binary release.

sudo npm install -g n sudo n v0.10.28

Fix MongoDB on ARM

Yes, Archlinux installs MongoDB but it has broken permissions :( and even if you fix it it still dies without error codes :((

Here is a quick workaround hack, run mongodb as root :D

# /etc/systemd/system/  [Unit] Description=High-performance, schema-free document-oriented database [Service] #User=mongodb User=root ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf --dbpath /var/lib/mongodb [Install]

And now it should be up and running :)

sudo systemctl start mongodb sudo systemctl status mongodb * mongodb.service - High-performance, schema-free document-oriented database    Loaded: loaded (/usr/lib/systemd/system/mongodb.service; enabled)    Active: active (running) since Wed 2014-08-13 10:02:45 CEST; 13s ago  Main PID: 531 (mongod)    CGroup: /system.slice/mongodb.service            `-531 /usr/bin/mongod --quiet --config /etc/mongodb.conf --dbpath /var/lib/mongodb Aug 13 10:02:45 alarmpi systemd[1]: Starting High-performance, schema-free document-oriented database... Aug 13 10:02:45 alarmpi systemd[1]: Started High-performance, schema-free document-oriented database. Aug 13 10:02:52 alarmpi mongod[531]: 2014-08-13T10:02:52.276+0200 Aug 13 10:02:54 alarmpi mongod[531]: 2014-08-13T10:02:52.721+0200 warning: 32-bit servers don't have journaling enabled by d...bility. Aug 13 10:02:54 alarmpi mongod[531]: 2014-08-13T10:02:52.738+0200 Hint: Some lines were ellipsized, use -l to show in full.

Fix Meteor specific node requirement

On the development computer you run meteor bundle myapp.tgz, on the Raspberry home server tar -xvzf myapp.tgz and you'll get a bundle/ directory with your meteor_app and node dependencies.

"These steps are needed everytime you update your app", so create a script if you plan to update your code often.

# recompile for ARM native meteor deps cd bundle/programs/server/node_modules/ # or bundle/server/node_modules on older Meteor versions rm -rf fibers bcrypt npm install fibers@1.0.1 bcrypt@0.7.7 npm install cd -

Downgrade nodejs to release compatible with MeteorJS and ARM architecture

open `bundle/programs/server/boot.js` and replace:

var MIN_NODE_VERSION = 'v0.10.29';


var MIN_NODE_VERSION = 'v0.10.28';

Now you should be able to run you app with:

PORT=3000 MONGO_URL=mongodb://localhost:27017/myapp node bundle/main.js

Persistence and boot startup with systemd

Cool the app works but I need it at boot and after mongodb! No prob.

# /etc/systemd/system/  [Unit] Description=My cool Meteor app on Linux ARM Raspberry [Service] User=myuser # User=root # if you want port 80 Environment=PORT=3000 MONGO_URL=mongodb://localhost:27017/myapp ExecStart=/usr/local/bin/node /home/myuser/Apps/bundle/main.js [Install]


sudo systemctl start myapp sudo systemctl enable myapp # to automatically start on boot or reboot

Done. You should see your app on http://my-pi-ip:3000 or http://my-pi-name.local:3000

And your app logs are at:

journalctl -u myapp

PS: the command to upgrade Archlinux "pacman -Syu" will "brick" your Raspberry installation,.. so if you want to upgrade all the packages choose carefully the package to update, like Linux kernel and low level libs.

corso javascript