UVicRocketry / PDP-Monitoring-System

The Propulsion Development Platform (PDP) Monitoring System is a web-based application that allows users to monitor the status of the engine controls and instrumentation. The PDP is a testbed for the development of propulsion systems, and the monitoring system is used to control valve actuation, monitor sensor readings, and record data.
0 stars 0 forks source link

Run Application with one command #20

Closed klemie closed 4 weeks ago

klemie commented 1 month ago

Description

Create a bash script that runs everything in one command. Take it one step further and get it to run on startup. Would love to dockerize it but serial and labjack is a no go because there external devices

Acceptance Criteria

QA Notes

Linked issues

Blocked by the PR

klemie commented 1 month ago

@jjderooy made this. but it has seemed to cause a bug or is part of a bug. Now we cant send serial and have instrumentation running at the same time. Might need to investigate this more.

jjderooy commented 1 month ago

Ok I fogor to commit and push the bash file I made on the mini pc but I know what the problem is. Basically, & on the end of a bash command (like the ones starting the python scripts) starts that in a new process in the background. When doing ctrl-c in the terminal shown by running the bash script, it only terminates the foreground process and not the background processes.

We can fix this by traping the ctrl+c input to run a command before exiting the bash script like this:

start.sh

trap ctrl_c INT

function ctrl_c() {
    echo "Trapped CTRL_C"
    kill -INT $PID1 $PID2 $PID3... # Send interrupt signal to each process
}

# Rest of original script here:
python read_labjack.py &
python ws.py &
...

I'll try and test this tmr and push it if it works.

jjderooy commented 1 month ago

I tested this among other variations and cannot for the life of me get it to work. Pressing ctrl+c interrupts the bash process, and then when the signal is trapped, it errors on kill -INT saying the PIDs aren't found. I'll have to do some more testing.

jjderooy commented 1 month ago

Done. I ended up not using bash and instead using python subprocesses.