Giter VIP home page Giter VIP logo

truenas-scale-restart-app's Introduction

truenas-scale-restart-app

This repository builds the danielriedl/truenas-scale-restart-app Docker Image.
It can be used to restart TrueNAS Scale Applications from anywhere, as it uses midclt from here.

Getting Started

These instructions will cover usage information and for the docker container

Prerequisities

In order to run this container you'll need TrueNAS Scale installed.

Usage

Container Parameters

docker run -it --rm danielriedl/truenas-scale-restart-app -h
usage: app.py [-h] [-s SERVICE_ID] [--start-api | --no-start-api] [-u URI] [-U USERNAME] [-P PASSWORD]

optional arguments:
  -h, --help            show this help message and exit
  -s SERVICE_ID, --service-id SERVICE_ID
                        The service ID to restart
  --start-api, --no-start-api
  -u URI, --uri URI
  -U USERNAME, --username USERNAME
  -P PASSWORD, --password PASSWORD

Example to test the connection

docker run -it --rm danielriedl/truenas-scale-restart-app \
    -s my-scale-app \
    -u ws://10.0.1.6:8080/websocket \
    -U root \
    -P MySecret

INFO:root:Will scale service my-scale-app to 0.
INFO:root:Created scale job 8296
INFO:root:Waiting for Job 8296 to finish
[... SNIP]
INFO:root:Waiting for Job 8296 to finish
INFO:root:Job 8296 succeeded
INFO:root:Will scale service my-scale-app to 1.
INFO:root:Created scale job 8301
INFO:root:Waiting for Job 8301 to finish
INFO:root:Job 8301 succeeded
INFO:root:Guess it worked, as this is the end of the script.

API

The application offers an Flask API. Start it with:

docker run -it --rm -p 8080:8080 danielriedl/truenas-scale-restart-app --start-api

Do a POST request to /restart do the same thing as above:

{
    "uri": "ws://10.0.1.6:8080/websocket",
    "username": "root",
    "password": "MySecret",
    "service_id": "my-scale-app"
}

Setup as TrueNAS Scale App

  • Go to /ui/apps and click top right on Launch Docker Image
  • (1) Application Name - Set Application Name to restart-app
  • (2) Container Images - Set Image repository to danielriedl/truenas-scale-restart-app
  • (3) Configure Entrypoint - Set Configure Container Args to --start-api
  • (6) Port Forwarding - Add one Rule to forward Container Port of 8080 to your desired Node Port e.g 10011
  • (13) Confirm Options - Click on Save

Now you can use the API from other TrueNAS Scale apps with following URL:
http://restart-app-ix-chart.ix-restart-app.svc.cluster.local:8080/restart

Or from somewhere else
http://ip-of-system:10011/restart

But y tho

So I made a mistake and was setting up home-assistant for my dad.
Kind of funny architecture, as I use the wireguard addon of the home-assistant chart to connect to his FritzBox VPN.
As our ISP decides randomly, when to assign new IPv4 Adresses to private households the connection drops from both sides,
resulting in a call from Dad Dan wtf nothing works.
So the goal was to restart the whole home-assistant TrueNAS Scale App of his installation, to reconnect everything.
This was approached by a simple node-red flow:
If certain entities are unavailable for 5 minutes trigger the /restart API endpoint.

Since then - no calls (atleast those where he's reporting network problems).

Authors

Acknowledgments

Everything relys on a forum thread I found while searching for solutions.
So kudos to MVP kiler129

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.