Server Status Thread

General discussion and socializing.

Re: Server Status Thread

Postby landreaum » Thu Oct 26, 2023 9:21 am

uudon wrote:
Hasta wrote:Won't bother to make clogs, inevitably step on a splinter and perish of the infected wound.

I wish they would add this back into the game, thorn in the foot was quite possibly the funniest way to die.


Not death by midges?
landreaum
 
Posts: 48
Joined: Sat Sep 17, 2022 7:27 pm

Re: Server Status Thread

Postby Borg_2 » Thu Oct 26, 2023 10:17 am

landreaum wrote:Not death by midges?


Fan of death by picking up a hedgehog myself.
Borg_2
 
Posts: 4
Joined: Wed Sep 07, 2011 1:00 am

Re: Server Status Thread

Postby loftar » Thu Oct 26, 2023 11:10 am

Oh my, I'm terribly sorry for the delay. Apparently my alarm didn't work for whatever reason, and of course it crashed like the actual second I went to sleep. Trying to debug now.
"Object-oriented design is the roman numerals of computing." -- Rob Pike
User avatar
loftar
 
Posts: 9045
Joined: Fri Apr 03, 2009 7:05 am

Re: Server Status Thread

Postby HamsterBBT » Thu Oct 26, 2023 11:16 am

All silk production will dead ? @loftar
HamsterBBT
 
Posts: 7
Joined: Tue Dec 28, 2021 9:08 am

Re: Server Status Thread

Postby meus » Thu Oct 26, 2023 11:19 am

Silk should be fine - seems that all timers are stopped while servers are down, so don't worry :)

Image
meus
 
Posts: 211
Joined: Sun Sep 04, 2011 3:00 pm

Re: Server Status Thread

Postby TheServant » Thu Oct 26, 2023 11:19 am

loftar wrote:Oh my, I'm terribly sorry for the delay. Apparently my alarm didn't work for whatever reason, and of course it crashed like the actual second I went to sleep. Trying to debug now.


You need a better alarm, we are using this one to see when it's back.

Code: Select all
import requests
from bs4 import BeautifulSoup
import time
import pygame

# Initialize pygame
pygame.mixer.init()

# Main loop to check the webpage and play the sound
while True:
    try:
        response = requests.get('https://www.havenandhearth.com/portal/')
        soup = BeautifulSoup(response.text, 'html.parser')

        status_div = soup.find('div', {'id': 'status'})
        if status_div and status_div.find('h2') and 'The server is up' in status_div.find('h2').text:
            print("Alarm: The server is up.")
            pygame.mixer.music.load(r'$path')
            pygame.mixer.music.play()
        else:
            print("The server might not be up or the status couldn't be found.")
           
    except requests.exceptions.RequestException as e:
        print(f"An error occurred: {e}")

    time.sleep(60)  # Sleep for 60 seconds (1 minute) before the next request
Image
User avatar
TheServant
 
Posts: 613
Joined: Wed Apr 09, 2014 1:07 am

Re: Server Status Thread

Postby loftar » Thu Oct 26, 2023 11:54 am

TheServant wrote:You need a better alarm

Probably, but I think you do too. Previously, I've just been grepping the syslog over SSH, but now I wrote this which should hopefully be a bit more robust:
Code: Select all
#!/usr/bin/python3

import sys, os, urllib.request, time
url = "http://www.havenandhearth.com/mt/srv-mon"
spath = os.path.join(os.getenv("HOME"), "audio/sounds/takeya.wav")

while True:
    try:
        with urllib.request.urlopen(url) as s:
            while ln := s.readline():
                words = ln.decode("ascii").split()
                if len(words) == 0:
                    sys.stderr.write("haven-alarm: connected\n")
                    continue
                if words[0] == "state" and words[1] == "crashed":
                    os.system("play -q " + spath)
    except urllib.error.URLError as exc:
        sys.stderr.write("haven-alarm: warning: could not connect: %s\n" % exc)
        time.sleep(60)
        sys.stderr.write("haven-alarm: reconnecting\n")
        continue

Using /mt/srv-mon is nicer, because it gives you the information both immediately, without having to do repetitive requests and without having to parse HTML.
"Object-oriented design is the roman numerals of computing." -- Rob Pike
User avatar
loftar
 
Posts: 9045
Joined: Fri Apr 03, 2009 7:05 am

Re: Server Status Thread

Postby Kiritosis » Fri Oct 27, 2023 3:43 pm

bruh
User avatar
Kiritosis
 
Posts: 8
Joined: Fri Dec 08, 2017 3:16 pm

Re: Server Status Thread

Postby Hubiektyw » Fri Oct 27, 2023 3:44 pm

Alarm seems to not be working.
balls
User avatar
Hubiektyw
 
Posts: 18
Joined: Sat Jan 07, 2017 5:19 pm
Location: Venore

Re: Server Status Thread

Postby frostbitten1 » Fri Oct 27, 2023 3:45 pm

bruh
User avatar
frostbitten1
 
Posts: 15
Joined: Tue May 08, 2012 11:44 pm

PreviousNext

Return to The Inn of Brodgar

Who is online

Users browsing this forum: Amazon [Bot], BLEX [Bot], Claude [Bot] and 8 guests