Skip to content

Latest commit

 

History

History
113 lines (88 loc) · 6.41 KB

unraid_guide.md

File metadata and controls

113 lines (88 loc) · 6.41 KB

Run TSD on unRAID

If video is your cup of tea, follow this awesome video guide put together by Ricky at SNR Tech Bytes.Thank you Ricky!

Install docker-compose

To run TSD on unRAID, you first must install Docker-Compose on the server. This can be done following the usual instructions found on the Docker-Compose Install Guide.

sudo curl -L "https://github.com/docker/compose/releases/download/1.27.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

However, because unRAID boots from a USB to RAM, this installation will not be persistent. To make sure that Docker-Compose gets installed every time the server boots, follow the following steps from this forum post.

# add the following lines to /boot/config/go on your unRAID server.
COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
curl -L https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

Just as a PSA, if this list of commands is incorrect in /boot/config/go unRAID will fail to boot.

This will install Docker-Compose permanently on your server.

Installing TSD

TSD can now be installed on your unRAID server the same way as the normal Linux method found on the [README.md]. However, I would recommend installing it in a directory other than the root home folder (/root/) as this data is not persistent between restarts. Either create a share specifically for TSD or install it in an existing share, I recommend /mnt/user/appdata/TheSpaghettiDetective. Here is the following command to do so.

cd /mnt/user/appdata/
git clone https://github.com/TheSpaghettiDetective/TheSpaghettiDetective.git
# from the README
cd TheSpaghettiDetective && docker-compose up -d

This will install TSD to your unRAID server! To update TSD, open up the terminal, change directory to the install directory, and run docker compose again.

cd /mnt/user/appdata/TheSpaghettiDetective # or where you install TSD to
git pull origin master
docker-compose up -d --force-recreate --build

Configuring TSD

Navigate to port 3334/admin on your server. For the following steps we will use tower.local as the server address with the root IP address as 192.168.1.10. Navigate to tower.local:3334/admin and log in with [email protected] and password supersecret

Go to Sites, click example.com, and change the Domain Name to your server IP address at port 3334, ex. 192.168.1.10:3334. Save the changes and exit out of the admin site.

Go to the non-admin site of the containter by navigating to tower.local:3334 and log in with the same credentials of [email protected]/supersecret. Add a printer and install TSD on the Ocotprint instance, setting the Server Address in Octoprint to your server address:port like http://192.168.1.10:3334, then copy/paste the secret token in the correct location.

To get email notifications working, go back to the Unraid terminal and navigate to the TSD installation directory with cd /mnt/user/appdata/TheSpaghettiDetective. Open the docker-compose.yml file with nano docker-compose.yml. You will need an app-specific password for your email if you use 2-factor authentication.

Set the following:

EMAIL_HOST: 'smtp.gmail.com'     # -> such as 'smtp.gmail.com'
EMAIL_HOST_USER: '[email protected]'
EMAIL_HOST_PASSWORD: 'abcdefghijklmnop' 
...
DEFAULT_FROM_EMAIL:  '[email protected]'

Rebuild the container (Note - if you are going to limit the CPU usage you can also change that now before rebuilding the container, see the below section) -

docker-compose up -d --force-recreate --build

Issues with the Installation

Unlike most containers that you install to unRAID, containers installed with Docker-Compose are limited in what you can do with them through the GUI. You cannot update them, change their logo, description, or do anything except for stop and restart them through the GUI. When you update the containers, you must remove the old and outdated ones manually from the command line using docker image rm.

Limit CPU Usage

By default TSD will use all of the processing power available from your server just for approximately 1 second every 10 seconds for a typical quad-core or 6-core system. You can use the following steps to limit TSD to only using a certain amount of CPU usage. This method doesn't actually constrain it to certain cores, but it sets the maximum processing power it can use overall. So if you have a 4 core / 8 thread system, as far as docker-compose is concerned you have 8 "cpus". Setting it to use 4 cpus will result in TSD using 50% of your processing power for about 2 seconds, vs the original 100% power for 1 second. If you have a 6-core/12-thread machine then cpus: 6 would be using half of your machine power.

  1. Use the Unraid GUI to Stop All running containers
  2. Open a terminal and navigate to the TSD install directory, then open the docker-compose.yml file:
cd /mnt/user/appdata/TheSpaghettiDetective
nano docker-compose.yml 
  1. Add cpus: 4 at the bottom of the services sections for ml_api: and web: under the line that starts with command: with the same indentation level as command.
services:
 ml_api:
   hostname: ml_api
   restart: unless-stopped
   build:
     context: ml_api
   environment:
       DEBUG: 'True'
       FLASK_APP: 'server.py'
       #ML_API_TOKEN:
       #HAS_GPU: 'False'
   command: bash -c "gunicorn --bind 0.0.0.0:3333 --workers 2 wsgi"
   cpus: 4

 web:
   <<: *web-defaults
   hostname: web
   ports:
     - "3334:3334"
   depends_on:
     - ml_api
   command: sh -c "python manage.py collectstatic --noinput && python manage.py migrate && python manage.py runserver --no>
   cpus: 4
  1. Save the changed file. Force the rebuild of the container with the following code:
docker-compose up -d --force-recreate  --build
  1. Navigate back to the Unraid GUI and Start All containers, you're all set!