Add health-check setup script
This commit is contained in:
parent
2af43ed499
commit
29a73e5963
|
@ -1,7 +1,25 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from urllib.request import urlopen, Request
|
from urllib.request import urlopen, Request
|
||||||
import urllib, json, os, traceback, discord
|
from dotenv import load_dotenv
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import urllib, json, os, traceback, discord, sys
|
||||||
|
|
||||||
|
|
||||||
|
# sc_precision is the number of hastings per siacoin
|
||||||
|
sc_precision = 10 ** 24
|
||||||
|
|
||||||
|
# Environment variable globals
|
||||||
|
api_endpoint, port, portal_name, bot_token, password = None, None, None, None, None
|
||||||
|
|
||||||
|
# Load dotenv file if possible.
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
env_path = Path(sys.argv[1])
|
||||||
|
load_dotenv(dotenv_path=env_path)
|
||||||
|
|
||||||
|
bot_token = os.environ["DISCORD_BOT_TOKEN"]
|
||||||
|
portal_name = os.getenv("PORTAL_NAME")
|
||||||
|
|
||||||
# Get a port or use default
|
# Get a port or use default
|
||||||
port = os.getenv("API_PORT")
|
port = os.getenv("API_PORT")
|
||||||
|
@ -9,13 +27,9 @@ if not port:
|
||||||
port = "9980"
|
port = "9980"
|
||||||
|
|
||||||
api_endpoint = "http://localhost:{}".format(port)
|
api_endpoint = "http://localhost:{}".format(port)
|
||||||
portal_name = os.getenv("PORTAL_NAME")
|
|
||||||
|
|
||||||
# sc_precision is the number of hastings per siacoin
|
|
||||||
sc_precision = 10 ** 24
|
|
||||||
|
|
||||||
# Discord bot initialization
|
# Discord bot initialization
|
||||||
bot_token = os.environ["DISCORD_BOT_TOKEN"]
|
|
||||||
client = discord.Client()
|
client = discord.Client()
|
||||||
channel_name = "skynet-portal-health-check"
|
channel_name = "skynet-portal-health-check"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
#! /usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get -y install python3-pip
|
||||||
|
|
||||||
|
pip3 install discord.py
|
||||||
|
|
||||||
|
downloadCheck="0 0,8,16 * * * ~/skynet-webportal/setup-scripts/health-checker.py ~/.sia/sia.env"
|
||||||
|
uploadCheck="0 0,8,16 * * * ~/skynet-webportal/setup-scripts/health-checker.py ~/.sia/sia-upload.env"
|
||||||
|
|
||||||
|
(crontab -u userhere -l; echo "$downloadCheck" ) | crontab -u userhere -
|
||||||
|
(crontab -u userhere -l; echo "$uploadCheck" ) | crontab -u userhere -
|
|
@ -1,3 +1,6 @@
|
||||||
SIA_DATA_DIR=""
|
SIA_DATA_DIR=""
|
||||||
SIA_API_PASSWORD=""
|
SIA_API_PASSWORD=""
|
||||||
SIA_WALLET_PASSWORD=""
|
SIA_WALLET_PASSWORD=""
|
||||||
|
API_PORT=""
|
||||||
|
PORTAL_NAME=""
|
||||||
|
DISCORD_BOT_TOKEN=""
|
||||||
|
|
Reference in New Issue