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:
parent
5a08fd78c6
commit
9cf1fb3ed8
@ -5,7 +5,7 @@ author = {
|
|||||||
"email":"maloja@krateng.dev",
|
"email":"maloja@krateng.dev",
|
||||||
"github": "krateng"
|
"github": "krateng"
|
||||||
}
|
}
|
||||||
version = 2,3,2
|
version = 2,3,3
|
||||||
versionstr = ".".join(str(n) for n in version)
|
versionstr = ".".join(str(n) for n in version)
|
||||||
links = {
|
links = {
|
||||||
"pypi":"malojaserver",
|
"pypi":"malojaserver",
|
||||||
@ -15,7 +15,7 @@ links = {
|
|||||||
requires = [
|
requires = [
|
||||||
"bottle>=0.12.16",
|
"bottle>=0.12.16",
|
||||||
"waitress>=1.3",
|
"waitress>=1.3",
|
||||||
"doreah>=1.5.3",
|
"doreah>=1.5.6",
|
||||||
"nimrodel>=0.6.3",
|
"nimrodel>=0.6.3",
|
||||||
"setproctitle>=1.1.10",
|
"setproctitle>=1.1.10",
|
||||||
"wand>=0.5.4",
|
"wand>=0.5.4",
|
||||||
|
@ -101,9 +101,9 @@ def getInstanceSupervisor():
|
|||||||
def start():
|
def start():
|
||||||
setup()
|
setup()
|
||||||
try:
|
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)
|
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
|
from doreah import settings
|
||||||
port = settings.get_settings("WEB_PORT")
|
port = settings.get_settings("WEB_PORT")
|
||||||
@ -126,14 +126,19 @@ def stop():
|
|||||||
pid_sv = getInstanceSupervisor()
|
pid_sv = getInstanceSupervisor()
|
||||||
if pid_sv is not None:
|
if pid_sv is not None:
|
||||||
os.kill(pid_sv,signal.SIGTERM)
|
os.kill(pid_sv,signal.SIGTERM)
|
||||||
|
return True
|
||||||
|
|
||||||
pid = getInstance()
|
else:
|
||||||
if pid is None:
|
|
||||||
print("Server is not running")
|
print("Server is not running")
|
||||||
return False
|
return False
|
||||||
else:
|
|
||||||
os.kill(pid,signal.SIGTERM)
|
# pid = getInstance()
|
||||||
print("Maloja stopped! PID: " + str(pid))
|
# 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
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ from .malojatime import register_scrobbletime, time_stamps, ranges
|
|||||||
from .urihandler import uri_to_internal, internal_to_uri, compose_querystring
|
from .urihandler import uri_to_internal, internal_to_uri, compose_querystring
|
||||||
from . import compliant_api
|
from . import compliant_api
|
||||||
from .external import proxy_scrobble
|
from .external import proxy_scrobble
|
||||||
from .__init__ import version
|
from .__pkginfo__ import version
|
||||||
from .globalconf import datadir
|
from .globalconf import datadir
|
||||||
# doreah toolkit
|
# doreah toolkit
|
||||||
from doreah.logging import log
|
from doreah.logging import log
|
||||||
|
@ -31,6 +31,7 @@ def update():
|
|||||||
def start():
|
def start():
|
||||||
try:
|
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)
|
||||||
|
log(p,module="supervisor")
|
||||||
|
|
||||||
except e:
|
except e:
|
||||||
log("Error starting Maloja: " + str(e),module="supervisor")
|
log("Error starting Maloja: " + str(e),module="supervisor")
|
||||||
@ -38,7 +39,7 @@ def start():
|
|||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
time.sleep(60)
|
|
||||||
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
today = now.year, now.month, now.day
|
today = now.year, now.month, now.day
|
||||||
@ -48,16 +49,20 @@ while True:
|
|||||||
if pid:
|
if pid:
|
||||||
|
|
||||||
restart = get_settings("DAILY_RESTART")
|
restart = get_settings("DAILY_RESTART")
|
||||||
if restart:
|
if restart not in [None,False]:
|
||||||
if today != lastrestart:
|
if today != lastrestart:
|
||||||
if now.hour == restart:
|
if now.hour == restart:
|
||||||
|
log("Daily restart...",module="supervisor")
|
||||||
os.kill(pid,signal.SIGTERM)
|
os.kill(pid,signal.SIGTERM)
|
||||||
start()
|
start()
|
||||||
lastrestart = today
|
lastrestart = today
|
||||||
|
|
||||||
else:
|
else:
|
||||||
log("Maloja is not running, restarting...",module="supervisor")
|
log("Maloja is not running, starting...",module="supervisor")
|
||||||
if get_settings("UPDATE_AFTER_CRASH"):
|
if get_settings("UPDATE_AFTER_CRASH"):
|
||||||
update()
|
update()
|
||||||
start()
|
start()
|
||||||
lastrestart = today
|
lastrestart = today
|
||||||
|
|
||||||
|
|
||||||
|
time.sleep(60)
|
||||||
|
@ -15,7 +15,7 @@ from doreah.logging import log
|
|||||||
from doreah.regular import yearly, daily
|
from doreah.regular import yearly, daily
|
||||||
|
|
||||||
from .external import api_request_track, api_request_artist
|
from .external import api_request_track, api_request_artist
|
||||||
from .__init__ import version
|
from .__pkginfo__ import version
|
||||||
from . import globalconf
|
from . import globalconf
|
||||||
from .globalconf import datadir
|
from .globalconf import datadir
|
||||||
|
|
||||||
|
38
setup.py
38
setup.py
@ -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))
|
|
Loading…
Reference in New Issue
Block a user