1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Temporary fix for supervisor issues

This commit is contained in:
Krateng 2020-03-08 01:18:31 +01:00
parent 5a08fd78c6
commit 9cf1fb3ed8
6 changed files with 32 additions and 60 deletions

View File

@ -5,7 +5,7 @@ author = {
"email":"maloja@krateng.dev",
"github": "krateng"
}
version = 2,3,2
version = 2,3,3
versionstr = ".".join(str(n) for n in version)
links = {
"pypi":"malojaserver",
@ -15,7 +15,7 @@ links = {
requires = [
"bottle>=0.12.16",
"waitress>=1.3",
"doreah>=1.5.3",
"doreah>=1.5.6",
"nimrodel>=0.6.3",
"setproctitle>=1.1.10",
"wand>=0.5.4",

View File

@ -37,7 +37,7 @@ def setup():
"SPOTIFY_API_ID":"Spotify Client ID",
"SPOTIFY_API_SECRET":"Spotify Client Secret"
}
SKIP = settings.get_settings("SKIP_SETUP")
print("Various external services can be used to display images. If not enough of them are set up, only local images will be used.")
@ -101,9 +101,9 @@ def getInstanceSupervisor():
def start():
setup()
try:
p = subprocess.Popen(["python3","-m","maloja.server"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
#p = subprocess.Popen(["python3","-m","maloja.server"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
sp = subprocess.Popen(["python3","-m","maloja.supervisor"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
print(col["green"]("Maloja started!") + " PID: " + str(p.pid))
print(col["green"]("Maloja started!"))
from doreah import settings
port = settings.get_settings("WEB_PORT")
@ -126,14 +126,19 @@ def stop():
pid_sv = getInstanceSupervisor()
if pid_sv is not None:
os.kill(pid_sv,signal.SIGTERM)
return True
pid = getInstance()
if pid is None:
else:
print("Server is not running")
return False
else:
os.kill(pid,signal.SIGTERM)
print("Maloja stopped! PID: " + str(pid))
# pid = getInstance()
# if pid is None:
# print("Server is not running")
# return False
# else:
# os.kill(pid,signal.SIGTERM)
# print("Maloja stopped! PID: " + str(pid))
return True

View File

@ -7,7 +7,7 @@ from .malojatime import register_scrobbletime, time_stamps, ranges
from .urihandler import uri_to_internal, internal_to_uri, compose_querystring
from . import compliant_api
from .external import proxy_scrobble
from .__init__ import version
from .__pkginfo__ import version
from .globalconf import datadir
# doreah toolkit
from doreah.logging import log

View File

@ -20,44 +20,49 @@ def get_pid():
return int(output)
except:
return None
def update():
log("Updating...",module="supervisor")
try:
os.system("pip3 install maloja --upgrade --no-cache-dir")
except:
log("Could not update.",module="supervisor")
def start():
try:
p = subprocess.Popen(["python3","-m","maloja.server"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
log(p,module="supervisor")
except e:
log("Error starting Maloja: " + str(e),module="supervisor")
while True:
time.sleep(60)
now = datetime.now()
today = now.year, now.month, now.day
pid = get_pid()
if pid:
restart = get_settings("DAILY_RESTART")
if restart:
if restart not in [None,False]:
if today != lastrestart:
if now.hour == restart:
log("Daily restart...",module="supervisor")
os.kill(pid,signal.SIGTERM)
start()
lastrestart = today
else:
log("Maloja is not running, restarting...",module="supervisor")
log("Maloja is not running, starting...",module="supervisor")
if get_settings("UPDATE_AFTER_CRASH"):
update()
start()
lastrestart = today
time.sleep(60)

View File

@ -15,7 +15,7 @@ from doreah.logging import log
from doreah.regular import yearly, daily
from .external import api_request_track, api_request_artist
from .__init__ import version
from .__pkginfo__ import version
from . import globalconf
from .globalconf import datadir

View File

@ -1,38 +0,0 @@
import setuptools
import importlib
module = importlib.import_module(setuptools.find_packages()[0])
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="malojaserver",
version=".".join(str(n) for n in module.version),
author=module.author["name"],
author_email=module.author["email"],
description=module.desc,
license="GPLv3",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/" + module.author["github"] + "/" + module.name,
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: OS Independent",
],
python_requires=">=3.5",
install_requires=module.requires,
package_data={'': module.resources},
include_package_data=True,
entry_points = {
"console_scripts":[
cmd + " = " + module.name + "." + module.commands[cmd]
for cmd in module.commands
]
}
)
import os
os.system("git tag v" + ".".join(str(n) for n in module.version))