Difference between revisions of "REST API"
| Line 1: | Line 1: | ||
| − | == Installing & Configuring Node (on Raspbian) | + | == Installing & Configuring Node (on Raspbian) == |
| − | I used a guide @ [http://blog.rueedlinger.ch/2013/03/raspberry-pi-and-nodejs-basic-setup/ rueedlinger.ch] for installing an up-to-date Node.js, as the one from apt-get was quite out of date. | + | I used a guide @ [http://blog.rueedlinger.ch/2013/03/raspberry-pi-and-nodejs-basic-setup/ rueedlinger.ch] for installing an up-to-date Node.js, as the one from apt-get was quite out of date. Also, I didn't have luck with Node 10.5, so I went with Node 10.2. |
You download binaries, so it's very straight forward. | You download binaries, so it's very straight forward. | ||
Revision as of 16:35, 23 October 2013
Contents |
Installing & Configuring Node (on Raspbian)
I used a guide @ rueedlinger.ch for installing an up-to-date Node.js, as the one from apt-get was quite out of date. Also, I didn't have luck with Node 10.5, so I went with Node 10.2.
You download binaries, so it's very straight forward.
sudo mkdir /opt/node wget http://nodejs.org/dist/v0.10.2/node-v0.10.2-linux-arm-pi.tar.gz tar xvzf node-v0.10.2-linux-arm-pi.tar.gz sudo cp -r node-v0.10.2-linux-arm-pi/* /opt/node
Change the default profile with
sudo nano /etc/profile
And add these lines before "export PATH"
NODE_JS_HOME="/opt/node" PATH="$PATH:$NODE_JS_HOME/bin"
And then log out and back in.
But, sudo might not see the paths well, so go ahead and symlink them
sudo ln -s /opt/node/bin/node /usr/bin/node sudo ln -s /opt/node/lib/ /usr/lib/node sudo ln -s /opt/node/bin/npm /usr/bin/npm sudo ln -s /opt/node/bin/node-waf /usr/bin/node-waf
Installing NPM Modules
Install "forever" as a global npm module
sudo npm install forever -g
(If you install it local first, before that, you might have to uninstall both, and then install globally)
Per node-i2c module readme on Raspbian
After installing i2c, you'll need to configure that the modules are available.
sudo vi /etc/modules
And add
i2c-bcm2708 i2c-dev
Then edit
sudo nano /etc/modprobe.d/raspi-blacklist.conf
And comment out the i2c module so it looks like:
# blacklist i2c-bcm2708
Load the kernel module
sudo modprobe i2c-bcm2708
...You may need to reboot at this point.
Check that it's there
pi@raspberrypi ~ $ sudo ls /dev/i2c-* -l crw------- 1 root root 89, 0 Oct 23 20:03 /dev/i2c-0 crw------- 1 root root 89, 1 Oct 23 20:03 /dev/i2c-1
And make it writeable.
sudo chmod o+rw /dev/i2c*
Setting up syslog
The server process uses node-syslog to get the logging done, which in turn requires some setup on the syslogd on your system. Again note, if you're using a pre-configured distro, this will already be setup for you.
In my example configuration in Pidora, we'll edit our syslog.conf
nano /etc/rsyslog.conf
And we'll add these two lines:
# Save veeOP daemon messages to veeop.log local5.* /var/log/veeop.conf
Then restart the daemon with
sudo service syslog restart
You'll probably also want to rotate this log, go and edit instructions for syslog
nano /etc/logrotate.d/veeop
And fill it with:
/var/log/veeop.log {
missingok
notifempty
size 5M
yearly
create 0600 root root
}