πŸ’‚ App management daemon for Tingbot OS
Python Makefile
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
testing
.gitignore
How it works.monopic
Makefile
README.md
setup.cfg
setup.py
tbbuttonsd.conf
tbbuttonsd.py
tbopen.py
tbprocessd.py
tbprocessd.service
tbtail.py

README.md

tbprocessd

This daemon launches apps on Tingbot. Because there's only one screen, there can be only one app running at once. Tbprocessd also collects the log messages from the running app and makes them available to stream over a ZMQ socket.

Commands are sent to the daemon via HTTP. Utilities tbopen and tbtail are supplied to simplify this process.

Also included is tbbuttonsd, which monitors button presses on the Tingbot and calls tbprocessd when the 'home' combo is pressed.

Setup

Running in development mode:

$ python tbprocessd.py

Installing (on Raspberry Pi):

$ sudo python setup.py install
$ sudo cp tbprocessd.service /etc/init.d

This installs the binary tbprocessd and the utility scripts (tbopen and tbtail).

What does it do?

      1. β€œtbprocessd runs the home screen”            
------------------------------------------------      
                                                      
                                        Ξ›             
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β•± β•²            
       β”‚                 β”‚   logs     β•±   β•²           
       β”‚   tbprocessd    │──────────▢╳ ZMQ β•³          
       β”‚                 β”‚            β•²   β•±           
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β•² β•±            
           β”‚        β–²                   V             
           β”‚        β”‚                                 
           β”‚        β”‚                                 
    starts β”‚        β”‚ logs (stdout, stderr)           
           β”‚        β”‚                                 
           β”‚        β”‚                                 
           β–Ό        β”‚                                 
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                            
       β”‚                 β”‚                            
       β”‚   Home screen   β”‚                            
       β”‚                 β”‚                            
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                            

On startup, tbprocessd starts the home screen, which is defined by the HOME_APP variable. This is configured in the upstart.conf, the current value is /apps/home. If the home screen crashes, tbprocessd will relaunch it.

2. β€œHome screen tells tbprocessd to open an app”      
-------------------------------------------------     
                                                      
                                                      
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                            
       β”‚                 β”‚                            
       β”‚   tbprocessd    β”‚                            
       β”‚                 β”‚                            
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                            
                β–²                                     
                β”‚                                     
                β”‚          HTTP                       
                └─────────────────────┐               
                                      β”‚               
                                      β”‚               
                                      β”‚               
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”‚               
       β”‚                 β”‚      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          
       β”‚   Home screen   │─────▢│//tbopen//β”‚          
       β”‚                 β”‚      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                            

The home screen tells tbprocessd to start an app using the tbopen script. The command would be something like $ tbopen /apps/weather.

       3. β€œtbprocessd starts the new app”             
-------------------------------------------------     
                                                      
                                        Ξ›             
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β•± β•²            
       β”‚                 β”‚   logs     β•±   β•²           
       β”‚   tbprocessd    │──────────▢╳ ZMQ β•³          
       β”‚                 β”‚            β•²   β•±           
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β•² β•±            
                β”‚   β–²                   V             
                β”‚   β”‚                                 
                β”‚   └──────────┐                      
         starts β”‚              β”‚ logs (stdout, stderr)
                └────────┐     β”‚                      
                         β”‚     β”‚                      
       \     /           β–Ό     β”‚                      
 β”Œβ”€β”€β”€β”€β”€β”€\───/──────┐  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             
 β”‚       \ /       β”‚  β”‚                 β”‚             
 β”‚   Home /creen   β”‚  β”‚   Weather app   β”‚             
 β”‚       / \       β”‚  β”‚                 β”‚             
 └──────/───\β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             
       /     \                                        

Home screen is killed and the new app is started. When tbprocessd is given a path to start, it will try to launch /apps/weather, or if this is not a binary, it will try /apps/weather/main, and if this does not exist, it will try python /apps/weather/main.py.

Logs from the new process can be accessed by running tbtail. This is going to be useful for Tide, but might also be useful when testing the home screen.

When the weather app exits, Home Screen will be launched again.

Running without installing

If you want to run without installing you just need to set the HOME_APP variable to whatever you want tbprocessd to run by default. Example terminal session:

$ export HOME_APP=../tbhome
$ python tbprocessd.py &
$ ./tbtail
...
^C
$ ./tbopen ../example_app
$ ./tbtail

This will run the app at ../tbhome, reboot it if it crashes, and run the example_app, if this crashes or exits, return to the home screen.