So it turns out it didn't work so well and after a day or two lifx-http becomes unresponsive. Also shortly after working on this LIFX 2.0 came out, breaking the current lifx-gem and introducing a cloud based http based API. I've since moved to using the lifx cloud API. Although I'm still interested in local non cloud communication with the LIFX bulbs.
Original article below
So I'm not a Ruby guy at all. My only current interest in Ruby is that the LIFX SDK and the LIFX HTTP API is written in Ruby.
The one other thing I'm doing in Ruby (without actually bothering to learn much Ruby outside of Stack Exchange driven development) is writing a bidirectional LIFX-MQTT bridge.
So I was playing around with trying to get Supervisor to run LIFX-HTTP. At some point I decided to upgrade my Ruby gems. Big mistake, this broke LIFX-HHTP and has lead me down a rabbit hole of Ruby gem version/dependancy management and the Ruby Version Manager (RVM).
Months ago when I was looking around to upgrade Ruby to version 2.0+ so i could run the LIFX gem I came across this page.
It seemed like an easy way to install Ruby on the Pi so I used that and it's worked well.
After upgrading my gems I discovered that lifx-http wasn't working. After reading through the Git Hub issues pages and trying a few things to no avail I decided that Rack version 1.6.0 was not playing well with lifx-http so the idea was to use RVM to move back to Rack 1.5.2
Once I started trying to use RVM to switch gemsets I started getting the apparently infamous "RVM is not a function" error.
With a bit of google I discovered that
source ~/.rvm/scripts/rvm fixes the problem on the Raspberry Pi (raspbian). Put it it your .bashrc so it's loaded on every new shell.
To make a long story short, I created and new gemset, installed lifx-http, it automatically installed rack 1.6.0 so I uninstalled it and manually installed rack 1.5.2.
Cool lifx-http working again, back to supervisor.
RVM uses wrapper scripts to load the correct environment, as I'm very new to RVM the wrapper generation syntax was confusing me.
rvm wrapper ruby@gemset [scope] [binary-name]
so I found the cheats way.
rvm repair wrappers
This generates wrappers for all the installed gems.
With lifx-http working again and having generated the wrappers its just a matter of creating a config for supervisor. Here's what worked for me.
[program:lifx-http] command=/home/justin/.rvm/gems/ruby-2.1.2@rack_1.5.2/wrappers/lifx-http directory=/home/justin/lexx stdout_logfile=/home/justin/lexx/log_lifx-http.txt stdout_logfile_maxbytes=5MB stdout_logfile_backups=1 redirect_stderr=true
So now I have lifx-http working under supervisor which is a great improvement over running it in a screen session.
lifx-http RUNNING pid 3660, uptime 1 day, 5:06:12 wemo RUNNING pid 2080, uptime 1 day, 5:44:22 supervisor>
Commentscomments powered by Disqus