1

I created several simple "microservices" for my Raspberry Pi (running Raspbian) for a variety of different purposes, for example:

  • HTTP server that reads temperature from a sensor and returns it when it receives a GET request
  • A RESTful service for accessing a database
  • Service that pings a remote server once per hour
  • ...

All of these are self-contained binary executables and I simply have them all in a folder and run them manually via SSH.

I was wondering if there's an existing solution, a "service runner" (or task manager) of sorts that could simplify this process. I'm thinking of something that can do the following:

  • Run the executables and save their STDERR to a log file.
  • Restart the executables and log / alert when they crash.
  • Support some way of updating the executables (and restarting them when this happens).

I'm aware these may be simple to the point where a BASH script might suffice, but I was wondering if there's an existing solution that just covers my use case? Is there an easier approach all together to just run multiple HTTP servers (or just tasks) on a Raspberry Pi?

(I'm specifically looking for lightweight solutions that would work with low-to-zero overhead on a Pi's hardware, which is why I'm asking here rather than some more general Linux SE)

  • something like supervisord should handle the first two points, might be able to do update handling via notifications too supervisord.org or Dockerise the whole thing, move your executables into containers and let Docker manage it. – tobyd May 16 '17 at 14:12
2

You have a few issues that you want to fix:

  • Software update
  • Remote run applications
  • Remote log capture

For each one there are very simple or complex solutions depending on the security level you want to have. I will present one possible simple scenario.

Software Update: Create your personal GIT repository using SSH transport. You don't need a full GIT server to do this, any Linux host, maybe with external disk, can hold it. Depending on your security needs, you can use SSL certificates to avoid password exchanges. Per your schedule, a cron job can kill your apps, do a git pull and restart them.

Remote run: A cron entries on your remote host, every few minutes, can keep your application alive. You may want to check if it's still running with a simple ps aux | grep ... query.

Remote log: You can use remote syslog, a practical way to collect all your logs in one point, or use rsync to copy/update your remote logs in one centralized host; using a unique name for each log file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.