The status of Active of the automatic startup program is active (running), but the web page cannot be accessed through the ip address

Description

I trained my own model on the jetson-nano with reference to the website [jetson-inference/docs/pytorch-ssd.md at master · dusty-nv/jetson-inference (github.com)](https://github.com/dusty-nv/jetson-inference/blob/master/docs/pytorch-ssd.md) and was able to run it successfully. I was also able to open Hello AI World on the web page with the ip address for real-time viewing. But when I set up the script to start on startup, I had trouble opening the Hello AI World Web page, even though the Active column showed active (running) when I used the systemctl status start. Service command.

Environment

All of my deep learning python files are in this directory:~/jetson-inference/python/www/cpflask
The following python files exist in this directory:utils.py util.py stream.py serial_utils.py model.py app.py
When I run the program in jetson I need to switch to the cpflask directory and execute the instructions:python3 app.py --detection /home/nvidia/jetson-inference/python/training/detection/ssd/models/plate/ssd-mobilenet.onnx --labels /home/nvidia/jetson-inference/python/training/detection/ssd/models/plate/labels.txt --confidence=0.8 --input-layer input_0 --output-layer scores,boxes --overlay pole --input-width=640 --input-height=480 --headless --port 1145 --headless --input /dev/video1
(By the way, I have two cameras, and I embedded the opencv-python program in the stream.py file so that I could use the other camera)
When i run this instructions,i can successfully open the hello ai world web.
I set up the start.sh and start.service files to run the startup program:
start.sh:(It is located under the /home/nvidi/directory)

#!/bin/bash
screen_name="web"

cd /home/nvidia/jetson-inference/python/www/cpflask/
chmod 777 /dev/ttyTHS1

echo "start screen"

screen -dmS $screen_name

cmd="python3 ./app.py --detection /home/nvidia/jetson-inference/python/training/detection/ssd/models/plate/ssd-mobilenet.onnx --labels /home/nvidia/jetson-inference/python/training/detection/ssd/models/plate/labels.txt --confidence=0.8 --input-layer input_0 --output-layer scores,boxes --overlay pole --input-width=640 --input-height=480 --headless --port 1145 --headless --input /dev/video0"
screen -x -S $screen_name -p 0 -X stuff "$cmd"
screen -x -S $screen_name -p 0 -X stuff $'\n'

echo "Over"
exit 0

start. Service:(It is located under the /etc/system/system/directory)

[Unit]
Description=Run a Custom Script at Startup
After=network.target

[Service]
ExecStart=/home/nvidia/start.sh
Type=forking

[Install]
WantedBy=graphical. Target

when everything was done,i use
systemctl daemon-reload
systemctl enable start. Service
sudo reboot
to start my program, then runsystemctl status service to see the status of my program and i had a problem:

start. Service - Run a Custom Script at Startup
   Loaded: loaded (/etc/systemd/system/start.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2024-03-31 17:31:57 CST; 44min ago
  Process: 7817 ExecStart=/home/nvidia/start.sh (code=exited, status=0/SUCCESS)
 Main PID: 7847 (screen)
    Tasks: 2 (limit: 4181)
   CGroup: /system.slice/start.service
           ├─7847 SCREEN -dmS web
           └─7851 /bin/sh

3月 31 17:31:57 nvidia-desktop systemd[1]: Starting Run a Custom Script at Startup...
3月 31 17:31:57 nvidia-desktop start.sh[7817]: start screen
3月 31 17:31:57 nvidia-desktop start.sh[7817]: Over
3月 31 17:31:57 nvidia-desktop systemd[1]: Started Run a Custom Script at Startup.

It shows running, but it doesn’t open the page over ip, and I’m not getting any data.

sometimes it will be this :

nvidia@nvidia-desktop:~/jetson-inference/python/www/cpflask$ systemctl status start.service
● start.service - Run a Custom Script at Startup
   Loaded: loaded (/etc/systemd/system/start.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2024-03-31 20:43:08 CST; 22s ago
  Process: 4705 ExecStart=/home/nvidia/start.sh (code=exited, status=1/FAILURE)

3月 31 20:43:04 nvidia-desktop sudo[4789]:     root : TTY=unknown ; PWD=/home/nvidia/jetson-infer
3月 31 20:43:04 nvidia-desktop sudo[4789]: pam_unix(sudo:session): session opened for user root b
3月 31 20:43:08 nvidia-desktop start.sh[4705]: Traceback (most recent call last):
3月 31 20:43:08 nvidia-desktop start.sh[4705]:   File "./app.py", line 25, in <module>
3月 31 20:43:08 nvidia-desktop start.sh[4705]:     import flask
3月 31 20:43:08 nvidia-desktop start.sh[4705]: ModuleNotFoundError: No module named 'flask'
3月 31 20:43:08 nvidia-desktop sudo[4789]: pam_unix(sudo:session): session closed for user root
3月 31 20:43:08 nvidia-desktop systemd[1]: start.service: Control process exited, code=exited sta
3月 31 20:43:08 nvidia-desktop systemd[1]: start.service: Failed with result 'exit-code'.
3月 31 20:43:08 nvidia-desktop systemd[1]: Failed to start Run a Custom Script at Startup.

Actually, i didn’t change anything.

Do you know what to do in this case ? Thanks for your help in advance.