Developer
-
Turn on our distrubted objects name-server if it has not been done already. If you are about to run this command, do not close the terminal.
$ python -m Pyro4.naming
-
Open up another terminal and run our service, make sure we have the above code running before running the code below.
$ python logging_service.py
-
(OPTIONAL) You can try out the fake data logger too.
$ python fake_logging_service.py
-
Open up another terminal and run the colling command to verify our service is working:
$ pyro4-nsc list
Production
This micro-service is found in the mikapod/logging_service.py
file and is responsible for polling the latest instrumentation data and saving it to our local persistent storage.
-
While being logged in as
pi
run the following:$ sudo vi /etc/systemd/system/mikapod_logging.service
-
Copy and paste the following contents.
[Unit] Description=Mikapod Data Logging Daemon After=multi-user.target [Service] Type=idle ExecStart=/home/pi/mikapod-soil-rpi/scripts/logging.sh Restart=on-failure KillSignal=SIGTERM [Install] WantedBy=multi-user.target
-
We can now start the Gunicorn service we created and enable it so that it starts at boot:
sudo systemctl start mikapod_logging sudo systemctl enable mikapod_logging
-
Confirm our service is running.
sudo systemctl status mikapod_logging.service
-
If the service is working correctly you should see something like this at the bottom:
raspberrypi systemd[1]: Started Mikapod Data Logging Daemon.
-
Congradulations, you have setup data logging micro-service! This service will be polling the latest instrumentation data and storing it in our persistent storage.
-
If you see any problems, run the following service to see what is wrong. More information can be found in this article.
sudo journalctl -u mikapod_logging