Your environment
Version : 2019.12.04 State: Updated
We are in a LAB environment with an OBD simulator.
We provide 13.5V to the device with a power supply capable of providing current of 2A.
We have 4G Internet connection on the device.
Subject of the issue
Hello AutoPi team or the other interested individuals.
We are trying to find a development workflow to execute custom code with AutoPi.
Focusing the acc_manager service for trying.
Our goal is to setup a socket connection with socketio (python-socketio)
, grab the realtime acceleration sensor data with a returner and emit it to clients over wireless LAN.
To achieve this we have created a hook and attached this hook to interrupt_handler
in acc_manager
worker, we attached our returner to the hook which we have created.
We have two main issues here.
To make the returner update we have to sequentially
- update our code in the returner
- sync it
- update the hook
- sync it
- update the worker process
- sync it
- IF the user interface asks us to restart the service
- restart
- THEN our new code in the returner updates sometimes and doesn’t update sometimes.
We usually have to reboot the device for the minion
service to restart and run the updated returner in the end.
This workflow is not sustainable.
Our question is:
Is there a way to do this faster and more efficent ?
What we have tried as an alternative is to sync the returner code to the device
then try to restart minion
service by calling autopi minionutils.request_restart
or autopi minionutils.restart
this never worked.
We either get an API not ready or if it restarts it doesn’t run the updated returner code which we have synced before.
We already have local and remote ssh connection to the device.
The ideal situation for us would be :
It would be much more efficent for us to work mostly in terminal and update necessary files then restart necessary services and log our output for debugging.
Passing through the cloud slows us down significantly.
We normally trace the logs /var/log/salt/minion
or /var/log/salt
, to debug our returner we append our output to a separate file and track it. It would be much nicer for us if the returner logs could be visible in /var/log/salt/minion
, how to do that ?
The second main issue is about python versions.
When we want to install a third party package as python-socketio
which python environment should we have to install it. I see that there are at least 4 different python versions running in the device. Is there a documentation about it ?
Our test code until now is this,
As a whole we have never managed to run it completely.
In customcode --> returner
#!/usr/bin/env python3
import logging
import sys
#Tries to import socketio
try:
import socketio
except Exception:
with open("/tmp/test.txt", "a") as file:
file.write("Can not import\n")
#Check for the environment
with open("/tmp/test.txt", "a+") as file:
file.write(sys.version+"\n")
file.write(sys.path+"\n")
file.write(sys.modules+"\n")
log = logging.getLogger(__name__)
sio = socketio.Client()
def returner(result):
with open("/tmp/test.txt", "a") as file:
file.write("{:}\n".format(result))
sio.emit('autopi_acc', "{:}\n".format(result))
sio.connect('http://192.168.4.2:3000')