diff --git a/maloja/__pkginfo__.py b/maloja/__pkginfo__.py index ee10c03..cdc8db4 100644 --- a/maloja/__pkginfo__.py +++ b/maloja/__pkginfo__.py @@ -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", diff --git a/maloja/controller.py b/maloja/controller.py index e45b2be..6f1aed4 100755 --- a/maloja/controller.py +++ b/maloja/controller.py @@ -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 diff --git a/maloja/database.py b/maloja/database.py index 77664ed..416ebc8 100644 --- a/maloja/database.py +++ b/maloja/database.py @@ -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 diff --git a/maloja/supervisor.py b/maloja/supervisor.py index ae8d4f6..1982230 100644 --- a/maloja/supervisor.py +++ b/maloja/supervisor.py @@ -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) diff --git a/maloja/utilities.py b/maloja/utilities.py index 660a9b6..dbd36f7 100644 --- a/maloja/utilities.py +++ b/maloja/utilities.py @@ -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 diff --git a/setup.py b/setup.py deleted file mode 100644 index ef53a28..0000000 --- a/setup.py +++ /dev/null @@ -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))