From a4eb588593145fdaa03d9c7d03020208997745d6 Mon Sep 17 00:00:00 2001 From: Snarr Date: Fri, 22 Mar 2024 16:24:33 +0000 Subject: [PATCH 1/6] Write block editor service --- install/block-editor.service | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 install/block-editor.service diff --git a/install/block-editor.service b/install/block-editor.service new file mode 100644 index 00000000..516b250a --- /dev/null +++ b/install/block-editor.service @@ -0,0 +1,12 @@ +[Unit] +Description=Block Code Editor Web Server +After=network.target + +[Service] +User=admin +WorkingDirectory=/home/project-blastpad/flask +ExecStart=flask --app serve run +Restart=always + +[Install] +WantedBy=multi-user.target From 5f052c51a583852ba20b4a0c1667b262c494fa4e Mon Sep 17 00:00:00 2001 From: Snarr Date: Fri, 22 Mar 2024 17:03:11 +0000 Subject: [PATCH 2/6] Add non-working service code for GUI --- install/block-editor.service | 2 +- install/launcher-gui.service | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 install/launcher-gui.service diff --git a/install/block-editor.service b/install/block-editor.service index 516b250a..78813ddb 100644 --- a/install/block-editor.service +++ b/install/block-editor.service @@ -4,7 +4,7 @@ After=network.target [Service] User=admin -WorkingDirectory=/home/project-blastpad/flask +WorkingDirectory=/home/admin/project-blastpad/flask ExecStart=flask --app serve run Restart=always diff --git a/install/launcher-gui.service b/install/launcher-gui.service new file mode 100644 index 00000000..1e1b8204 --- /dev/null +++ b/install/launcher-gui.service @@ -0,0 +1,10 @@ +[Unit] +Description=Launcher GUI +After=network.target + +[Service] +ExecStart=/bin/sh -c "/usr/bin/python3 /home/admin/project-blastpad/home/homeScreenGui.py" +Restart=always + +[Install] +WantedBy=multi-user.target From c65d4bb837d4b21fac83331e05e8e172f9963d3b Mon Sep 17 00:00:00 2001 From: Jacob Snarr Date: Fri, 22 Mar 2024 13:08:14 -0400 Subject: [PATCH 3/6] Add graphical target and environment vars --- install/launcher-gui.service | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/install/launcher-gui.service b/install/launcher-gui.service index 1e1b8204..104a2546 100644 --- a/install/launcher-gui.service +++ b/install/launcher-gui.service @@ -1,10 +1,14 @@ [Unit] Description=Launcher GUI -After=network.target +After=graphical.target +Wants=graphical.target [Service] -ExecStart=/bin/sh -c "/usr/bin/python3 /home/admin/project-blastpad/home/homeScreenGui.py" +User=admin +Environment="DISPLAY=:0.0" +Environment="XAUTHORITY=/home/pi/.Xauthority" +ExecStart=/usr/bin/python3 /home/admin/project-blastpad/home/homeScreenGui.py Restart=always [Install] -WantedBy=multi-user.target +WantedBy=graphical.target \ No newline at end of file From f591f05c0c16684818320acd846631ab000142c8 Mon Sep 17 00:00:00 2001 From: Snarr Date: Fri, 22 Mar 2024 17:22:41 +0000 Subject: [PATCH 4/6] Add more to service, non-working --- install/launcher-gui.service | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/install/launcher-gui.service b/install/launcher-gui.service index 104a2546..8eb5ffc3 100644 --- a/install/launcher-gui.service +++ b/install/launcher-gui.service @@ -4,11 +4,13 @@ After=graphical.target Wants=graphical.target [Service] +Type=simple User=admin -Environment="DISPLAY=:0.0" +Environment="DISPLAY=:0" Environment="XAUTHORITY=/home/pi/.Xauthority" +ExecStartPre=/usr/bin/printenv ExecStart=/usr/bin/python3 /home/admin/project-blastpad/home/homeScreenGui.py Restart=always [Install] -WantedBy=graphical.target \ No newline at end of file +WantedBy=graphical.target From ef17440561bf8dfa0b38fb895a2f84e14e341cd2 Mon Sep 17 00:00:00 2001 From: Jacob Snarr Date: Fri, 22 Mar 2024 13:39:13 -0400 Subject: [PATCH 5/6] Export display in line --- install/launcher-gui.service | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/install/launcher-gui.service b/install/launcher-gui.service index 8eb5ffc3..3e56d167 100644 --- a/install/launcher-gui.service +++ b/install/launcher-gui.service @@ -7,9 +7,8 @@ Wants=graphical.target Type=simple User=admin Environment="DISPLAY=:0" -Environment="XAUTHORITY=/home/pi/.Xauthority" -ExecStartPre=/usr/bin/printenv -ExecStart=/usr/bin/python3 /home/admin/project-blastpad/home/homeScreenGui.py +Environment="XAUTHORITY=/home/admin/.Xauthority" +ExecStart=/bin/bash -c "export DISPLAY=:0; /usr/bin/python3 /home/admin/project-blastpad/home/homeScreenGui.py" Restart=always [Install] From a75d7fb5273013a6ae4499b8697cacdab3b44d5c Mon Sep 17 00:00:00 2001 From: Snarr Date: Fri, 22 Mar 2024 17:46:26 +0000 Subject: [PATCH 6/6] Add service readme tutorial --- install/Service-README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 install/Service-README.md diff --git a/install/Service-README.md b/install/Service-README.md new file mode 100644 index 00000000..367360d8 --- /dev/null +++ b/install/Service-README.md @@ -0,0 +1,21 @@ +# Services + +In this install folder there are two service files. + +To set up these services, first move them into the `/etc/systemd/system/` directory. + +From there, you can use the following commands to manage the services: + +`systemctl start ` +*Start the service* + +`systemctl enable ` +*Enables the service so it will start after future reboots* + +`systemctl status ` +*Displays basic information about the status of the service (i.e. whether it is running or not)* + +`journalctl -u ` +*Displays service stdout logs, useful for if a service crashes and you need to debug* + +