add host
- small clean up
This commit is contained in:
parent
b51712cb87
commit
6cb493eba7
7 changed files with 29 additions and 21 deletions
|
@ -36,6 +36,8 @@ pushover.user_key =
|
|||
[WEB]
|
||||
# should we enable the webserver which is just a simple, simple, simple webui to view the logs
|
||||
web.enabled = false
|
||||
# the host to listen on. localhost or 0.0.0.0 are the two common options
|
||||
web.host = localhost
|
||||
# the port to run on
|
||||
web.port = 9547
|
||||
# the app root / web folder / root / many other names . MUST contain a trailing '/'
|
||||
|
|
|
@ -27,7 +27,6 @@ def choose_user_agent():
|
|||
|
||||
|
||||
class ConfigReader(ConfigParser):
|
||||
|
||||
required_values = {
|
||||
'DEFAULT': {
|
||||
'enabled': ('true', 'false'),
|
||||
|
@ -75,6 +74,7 @@ class ConfigReader(ConfigParser):
|
|||
},
|
||||
'WEB': {
|
||||
'web.enabled': 'false',
|
||||
'web.host': '0.0.0.0',
|
||||
'web.app_root': '/',
|
||||
'web.port': '9647',
|
||||
'web.ssl': 'true',
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
import datetime
|
||||
import threading
|
||||
from datetime import timedelta, datetime
|
||||
from random import randint
|
||||
from threading import Thread
|
||||
from time import sleep
|
||||
|
||||
from dateutil import tz
|
||||
|
||||
import log
|
||||
from enter_giveaways import EnterGiveaways
|
||||
|
||||
|
@ -52,7 +56,9 @@ class GiveawayThread(threading.Thread):
|
|||
|
||||
logger.info("🔴 All giveaways evaluated.")
|
||||
random_seconds = randint(1740, 3540) # sometime between 29-59 minutes
|
||||
logger.info(f"🛋 Going to sleep for {random_seconds / 60} minutes.")
|
||||
when_to_start_again = datetime.now(tz=tz.tzlocal()) + timedelta(seconds=random_seconds)
|
||||
logger.info(f"🛋 Going to sleep for {random_seconds / 60} minutes. "
|
||||
f"Will start again at {when_to_start_again}")
|
||||
sleep(random_seconds)
|
||||
|
||||
def run(self):
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import http.client
|
||||
import urllib
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from tables import TableNotification
|
||||
import log
|
||||
from tables import TableNotification
|
||||
|
||||
logger = log.get_logger(__name__)
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@ class TableNotification(Base):
|
|||
.filter_by(type='won').all()
|
||||
actual = []
|
||||
for r in within_3_days:
|
||||
if r.created_at.replace(tzinfo=tz.tzutc()).astimezone(tz.tzlocal()).date() == datetime.now(tz=tz.tzlocal()).date():
|
||||
if r.created_at.replace(tzinfo=tz.tzutc()).astimezone(tz.tzlocal()).date() == datetime.now(
|
||||
tz=tz.tzlocal()).date():
|
||||
actual.append(r)
|
||||
return actual
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ class WebServerThread(threading.Thread):
|
|||
Thread.__init__(self)
|
||||
self.exc = None
|
||||
self.config = config
|
||||
self.host = config['WEB'].get('web.host')
|
||||
self.port = config['WEB'].getint('web.port')
|
||||
self.ssl = config['WEB'].getboolean('web.ssl')
|
||||
self.enabled = config['WEB'].getboolean('web.enabled')
|
||||
|
@ -63,9 +64,9 @@ class WebServerThread(threading.Thread):
|
|||
if self.enabled:
|
||||
logger.info("Webserver Enabled. Running")
|
||||
if self.ssl:
|
||||
app.run(port=self.port, host="0.0.0.0", ssl_context='adhoc')
|
||||
app.run(port=self.port, host=self.host, ssl_context='adhoc')
|
||||
else:
|
||||
app.run(port=self.port, host="0.0.0.0")
|
||||
app.run(port=self.port, host=self.host)
|
||||
else:
|
||||
logger.info("Webserver NOT Enabled.")
|
||||
|
||||
|
|
Loading…
Reference in a new issue