I tried starting an experiment last night, but when I checked on it several hours later, I noticed it had stopped. I think I ran it with nohup like this:
$ nohup python /home/pioreactor/salt_temp_cycle_experiment.py > stc_log.out %
I was pretty tired, so I just restarted the experiment from terminal on a different computer and went to bed, and I’m trying to piece together what happened just now.
Around ~8:04 PM last night, I ran started the experiment via nohup python /home/pioreactor/salt_temp_cycle_experiment.py > stc_log.out %
through terminal on my laptop. I verified this was the command by viewing a timestamped command history from the laptop terminal, and confirmed the time by looking at the stc_log.out log file. [Note - All timestamps in log files are +8 hours ahead of my timezone and I am converting the times.] Everything seemed to be working properly.
At 10:21 PM last night, the experiment exited due to a signal Hangup. Here is the relevant portion from the log file. I cleaned up some of the excerpt, but there are also some weird artifacts in the log file. I am not sure what caused them and I left them in.
Disconnect caused by [36m2023-01-11T06:21:00+0000 DEBUG [app] [temperature_control] Exiting caused by signal Hangup.
stc_log.out excerpt
e[32m2023-01-11T06:04:19+0000 INFO [app] [add_media] 0.5mLe[0m
e[36m2023-01-11T06:04:20+0000 DEBUG [app] [add_media] Initialized GPIO-13 using hardware-timing, initial frequency = 200.0 hz.e[0m
e[36m2023-01-11T06:04:25+0000 DEBUG [app] [add_media] Cleaned up GPIO-13.e[0m
e[36m2023-01-11T06:04:25+0000 DEBUG [app] [add_media] Cleaned up GPIO-13.e[0m
e[32m2023-01-11T06:04:31+0000 INFO [app] [remove_waste] 0.5mLe[0m
…
e[36m2023-01-11T06:18:36+0000 DEBUG [app] [temperature_control] features={‘previous_heater_dc’: 0, ‘room_temp’: 22.0, ‘time_series_of_temp’: […]}e[0m
e[36m2023-01-11T06:21:00+0000 DEBUG [app] [temperature_control] Exiting caused by signal Hangup.e[0m
e[36m2023-01-11T06:21:02+0000 DEBUG [app] [PWM-18] Cleaned up GPIO-18.e[0m
e[36m2023-01-11T06:21:03+0000 DEBUG [app] [temperature_automation] Disconnected.e[0m
e[36m2023-01-11T06:21:04+0000 DEBUG [app] [temperature_automation] Disconnected successfully from MQTT.e[0m
e[32m2023-01-11T06:21:05+0000 INFO [app] [temperature_control] Disconnected.e[0m
e[36m2023-01-11T06:21:06+0000 DEBUG [app] [temperature_control] Disconnected successfully from MQTT.e[0m
e[36m2023-01-11T06:21:07+0000 DEBUG [app] [dosing_control] Exiting caused by Python atexit.e[0m
e[36m2023-01-11T06:21:07+0000 DEBUG [app] [dosing_automation] Disconnected.e[0m
e[36m2023-01-11T06:21:07+0000 DEBUG [app] [dosing_automation] Disconnected successfully from MQTT.e[0m
e[32m2023-01-11T06:21:08+0000 INFO [app] [dosing_control] Disconnected.e[0m
e[36m2023-01-11T06:21:09+0000 DEBUG [app] [dosing_control] Disconnected successfully from MQTT.e[0m
Right at midnight, as I was about to go to bed, I used my phone to check the experiment via the web GUI and saw it had stopped. I went to my desktop, opened a terminal via SSH, and started the experiment again via nohup python /home/pioreactor/salt_temp_cycle_experiment.py > stc_2_logs.out &
, this time outputting to a new log file. The experiment has been running fine since then, but I also haven’t shut off this computer since then and I have kept the terminal window open.
Since I started the experiment on my laptop terminal window at 8:04 PM, and it disconnected at 10:21 PM, there are three possible possible causes that come to mind. The laptop enters sleep mode after an hour of disuse, so maybe I last checked my laptop around 9:20 PM last night and it entered sleep mode at 10:21 PM. Alternatively, I could also have closed the terminal window sometime last night sometime after starting the experiment (maybe at 10:21?). I don’t remember doing this, but that was one possible cause I could think of. Lastly, sometimes my house has issues with the internet connection. The WiFi network will still be up and running, but devices connected to it won’t have access to the internet, and sometimes my roommates will restart it. I don’t think this happened last night, but I just realized that this could be an issue at some point in the future (and possible cause a signal hangup?).
How can I prevent this issue from occurring again? I had wanted my program to run in the background, and continue running even after exiting the terminal or shutting off my computer.
On a related topic, is it possible to attach a monitor and keyboard directly to the Pioreactor and use terminal without having to resort to SSH from another computer? I know it is possible with certain raspberry pi operating systems, but I am unsure how the pioreactor software might affect that capability. When I was installed the pioreactor software by flashing the software image onto the raspberry pi SD card, I had assumed I was installing a custom operating system onto the raspberry pi and that it wouldn’t have the functionality of a full raspberry pi operating system. Now that I have a bit more familiarity with using a raspberry, I am starting to suspect that isn’t the case. Regardless, one time I did try plugging in an old monitor to my pi but couldn’t get it to work (it would only display a black and white screen with a bunch of jibberish/random characters and blank spaces). I think it may have also given me some sort of error message.
Is there any special way to connect my pi to an external monitor and keyboard (can I just plug them in and have it run)? Given my last experience with plugging it in, I don’t want to accidentally mess something up while I currently have an experiment running.