NOALBS / nginx-obs-automatic-low-bitrate-switching

Simple app to automatically switch scenes in OBS based on the current bitrate fetched from the NGINX stats page.
http://noalbs.com
MIT License
340 stars 77 forks source link

NOALBS - Start up on boot failed #93

Open codexual opened 2 years ago

codexual commented 2 years ago

Before updating to NOALBS v2.5.2 I was using the older (NPM) version. And the way I start up on boot what using "PM2" which starts up any app.js file. However you can't use this in the latest update (RUST lang) - I am using Ubuntu Server 20.04.3 on Raspi 4 (not sure if I am using 4GB or 8GB) just fyi.

So I created a simple "autostart.sh" script

cd /root/NOALBS cargo go

Using !#/bin/bash with and without on 1st line. When I run the script from the terminal works flawlessly ./autostart.sh

But when creating a "crontab -e" @reboot sh /root/autostart.sh Nothing happens upon reboot

My other failed solution is creating a systemd service File name - /etc/systemd/system/autostart.service

[Unit] Description=autostart script

[Service] ExecStart=/root/autostart.sh #And also used this instead - /bin/bash /root/NOALBS2/autostart.sh

[Install] WantedBy=multi-user.target

Also should mention it has writable permissions 0777 on the autostart.sh, and the entire folder of NOALBS.

Next command systemctl enable autostart then to officially run it service autostart start

Nothing happens, check the logs service autostart status

root@ubuntu:~/NOALBS2# service autostart status ● autostart.service - Autostart script Loaded: loaded (/etc/systemd/system/autostart.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sun 2022-02-13 14:47:46 UTC; 3s ago Process: 10608 ExecStart=/bin/bash /root/NOALBS2/autostart.sh (code=exited, status=101) Main PID: 10608 (code=exited, status=101)

Feb 13 14:47:46 ubuntu systemd[1]: Started Autostart script. Feb 13 14:47:46 ubuntu bash[10609]: error: could not find Cargo.toml in / or any parent directory Feb 13 14:47:46 ubuntu systemd[1]: autostart.service: Main process exited, code=exited, status=101/n/a Feb 13 14:47:46 ubuntu systemd[1]: autostart.service: Failed with result 'exit-code'.

I was thinking maybe because "autostart.sh" wasn't in NOALBS folder, moved it, modified the "systemd service" with the updated path and the autostart.sh and remove "cd /root/NOALBS". Same error. So if anyone knows how to help me or have a different solution for NOALBS to start up on boot, that would be lit. Sorry for my inexperience-ness! :|

b3ck commented 2 years ago

have you tried using the executable? rather then using the source?

https://github.com/715209/nginx-obs-automatic-low-bitrate-switching/releases/download/v2.5.3/noalbs-v2.5.3-x86_64-unknown-linux-musl.tar.gz

image

TaRs-one commented 1 year ago

Hey, setup: Raspberry Pi 3 B+ build: cargo build NOALBS

what i have tried without success

I also tried with crone tab and rc.local. With the CLI it starts without problems, but as a crone tab NOALBS starts but it finds no .env and no config.

TaRs-one commented 1 year ago

I created a service

[Unit] Description=Examplesystemd service.

[Service] Type=simple ExecStart=/home/pi/nginx-obs-automatic-low-bitrate-switching/noalbs

[Install] WantedBy=multi-user.target

Start service

systemctl start albs.service

after starting get errors. no .env and no config

all is in the same folder

fehller autostart

715209 commented 1 year ago

@TaRs-one you also have to change the WorkingDirectory.

[Unit]
Description=NOALBS service
After=network.target

[Service]
Restart=always
User=root
Group=root
WorkingDirectory=/home/pi/nginx-obs-automatic-low-bitrate-switching
ExecStart=/home/pi/nginx-obs-automatic-low-bitrate-switching/noalbs
SyslogIdentifier=NOALBS

[Install]
WantedBy=multi-user.target