1

I use a raspberry pi to collect temperature data from homebrewing activity and store it in both a MySQL database and a MongoDB database on my RPi. In addition, I have a bottle/python web server on the RPi.

I use a screen for the mongod server and another screen for the python script that collects the temperatures. The MySql server runs as a service so I don't need to use screen for that.

This is great but whenever I have a poweroutage everything goes haywire. I just suffered my last outage a week ago and have made the following adjustments to m /etc/rc.local file:

#Turn on Temperature sensors
sudo modprobe w1-gpio
sudo modprobe w1-therm

#Turn on MySQL Server
sudo service mysql start

#Turn on mongod
mongod

#Run python script
/home/pi/thermometer_object.py

I was told to put everything in the /etc/rc.local file for anything I wanted to execute when the RPi boots up.

The MySQL server stars when the RPi reboots. But the mongod server does not. (Yep, mongod is in the path). The python script didn't start (presumably because the mongod isn't on). When I manually execute the python script, I'm told that the mongod isn't on. When I turn it on, I can execute the script, which tells me the mysql service started.

I don't know where to find a dump to see what happened .. all I know is that there is no mongod or python files running (ps -e | grep python or ps -e | grep mongod).

But this is still unsatisfactory even if it worked. I require the mongod and the python script to be in a screen, so I can SSH in at will to check up on it (particularly because the python script continuously prints to the screen the temperature of my beer).

TLDR: Is there anyway I can activate two different screens for two operations from /etc/rc.local ?

Matthew Moisen
  • 745
  • 5
  • 11
  • 25

1 Answers1

3

First, don't use sudo in rc.local or any other init script -- they run as root anyway.

Second, this:

service mysql start

is a little zany in an init script, because if it's a service, it has it's own script (that's pretty much what defines a service) -- you just need to enable it:

sudo update-rc.d mysql enable

I use sudo there because I don't mean for you to put this in a script; just run it once and init will add this to the start-up services -- i.e., mysql will now start at boot and get shutdown properly on halt.

I have no idea why mongod would not start at boot, but you might want to look at /var/log/syslog for errors. If you installed mongodb from a raspbian package, it probably has a service too (look in /etc/init.d), although it looks to me like there is no package :/

goldilocks
  • 58,859
  • 17
  • 112
  • 227