mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Update error printing to keep only what's necessary in jobs
This commit is contained in:
parent
41540fcda2
commit
f15b5eea61
20 changed files with 48 additions and 66 deletions
|
|
@ -6,7 +6,6 @@ from os import getenv, sep
|
|||
from os.path import join
|
||||
from pathlib import Path
|
||||
from sys import exit as sys_exit, path as sys_path
|
||||
from traceback import format_exc
|
||||
|
||||
for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in (("deps", "python"), ("utils",), ("db",), ("core", "backup"))]:
|
||||
if deps_path not in sys_path:
|
||||
|
|
@ -87,8 +86,8 @@ try:
|
|||
update_cache_file(JOB.db, backup_dir)
|
||||
except SystemExit as e:
|
||||
status = e.code
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 2
|
||||
LOGGER.error(f"Exception while running backup-data.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running backup-data.py :\n{e}")
|
||||
|
||||
sys_exit(status)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from os import getenv, sep
|
|||
from os.path import join
|
||||
from pathlib import Path
|
||||
from sys import exit as sys_exit, path as sys_path
|
||||
from traceback import format_exc
|
||||
|
||||
for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in (("deps", "python"), ("utils",), ("db",))]:
|
||||
if deps_path not in sys_path:
|
||||
|
|
@ -114,8 +113,8 @@ try:
|
|||
exit_status = 1
|
||||
except SystemExit as e:
|
||||
exit_status = e.code
|
||||
except:
|
||||
except BaseException as e:
|
||||
exit_status = 2
|
||||
LOGGER.error(f"Exception while running bunkernet-data.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running bunkernet-data.py :\n{e}")
|
||||
|
||||
sys_exit(exit_status)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
from os import getenv, sep
|
||||
from os.path import join
|
||||
from sys import exit as sys_exit, path as sys_path
|
||||
from traceback import format_exc
|
||||
|
||||
for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in (("deps", "python"), ("utils",), ("db",))]:
|
||||
if deps_path not in sys_path:
|
||||
|
|
@ -84,8 +83,8 @@ try:
|
|||
LOGGER.info("Successfully saved BunkerNet data to db cache")
|
||||
except SystemExit as e:
|
||||
exit_status = e.code
|
||||
except:
|
||||
except BaseException as e:
|
||||
exit_status = 2
|
||||
LOGGER.error(f"Exception while running bunkernet-register.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running bunkernet-register.py :\n{e}")
|
||||
|
||||
sys_exit(exit_status)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from os import getenv, sep
|
|||
from os.path import join
|
||||
from pathlib import Path
|
||||
from sys import exit as sys_exit, path as sys_path
|
||||
from traceback import format_exc
|
||||
from base64 import b64decode
|
||||
from typing import Tuple, Union
|
||||
|
||||
|
|
@ -143,8 +142,8 @@ try:
|
|||
JOB.del_cache("key.pem", service_id=first_server)
|
||||
except SystemExit as e:
|
||||
status = e.code
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 2
|
||||
LOGGER.error(f"Exception while running custom-cert.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running custom-cert.py :\n{e}")
|
||||
|
||||
sys_exit(status)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
from os import getenv, sep
|
||||
from os.path import join
|
||||
from sys import exit as sys_exit, path as sys_path
|
||||
from traceback import format_exc
|
||||
|
||||
for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in (("deps", "python"), ("utils",), ("db",))]:
|
||||
if deps_path not in sys_path:
|
||||
|
|
@ -18,8 +17,8 @@ status = 0
|
|||
try:
|
||||
# Restoring the backup failover configuration
|
||||
JOB = Job(LOGGER)
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 2
|
||||
LOGGER.error(f"Exception while running failover-backup.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running failover-backup.py :\n{e}")
|
||||
|
||||
sys_exit(status)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ from os import getenv, sep
|
|||
from os.path import join
|
||||
from pathlib import Path
|
||||
from sys import exit as sys_exit, path as sys_path
|
||||
from traceback import format_exc
|
||||
from typing import Optional
|
||||
|
||||
for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in (("deps", "python"), ("utils",), ("db",))]:
|
||||
|
|
@ -101,6 +100,7 @@ try:
|
|||
if not tmp_path.is_file():
|
||||
sys_exit(2)
|
||||
LOGGER.warning("Falling back to project cached mmdb file.")
|
||||
dl_mmdb = False
|
||||
|
||||
# Try to load it
|
||||
LOGGER.info("Checking if mmdb file is valid ...")
|
||||
|
|
@ -122,8 +122,8 @@ try:
|
|||
status = 1
|
||||
except SystemExit as e:
|
||||
status = e.code
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 2
|
||||
LOGGER.error(f"Exception while running mmdb-asn.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running mmdb-asn.py :\n{e}")
|
||||
|
||||
sys_exit(status)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ from os import getenv, sep
|
|||
from os.path import join
|
||||
from pathlib import Path
|
||||
from sys import exit as sys_exit, path as sys_path
|
||||
from traceback import format_exc
|
||||
from typing import Optional
|
||||
|
||||
for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in (("deps", "python"), ("utils",), ("db",))]:
|
||||
|
|
@ -101,6 +100,7 @@ try:
|
|||
if not tmp_path.is_file():
|
||||
sys_exit(2)
|
||||
LOGGER.warning("Falling back to project cached mmdb file.")
|
||||
dl_mmdb = False
|
||||
|
||||
# Try to load it
|
||||
LOGGER.info("Checking if mmdb file is valid ...")
|
||||
|
|
@ -122,8 +122,8 @@ try:
|
|||
status = 1
|
||||
except SystemExit as e:
|
||||
status = e.code
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 2
|
||||
LOGGER.error(f"Exception while running mmdb-country.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running mmdb-country.py :\n{e}")
|
||||
|
||||
sys_exit(status)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
from os import getenv, sep
|
||||
from os.path import join
|
||||
from sys import exit as sys_exit, path as sys_path
|
||||
from traceback import format_exc
|
||||
|
||||
for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in (("deps", "python"), ("utils",))]:
|
||||
if deps_path not in sys_path:
|
||||
|
|
@ -80,8 +79,8 @@ try:
|
|||
)
|
||||
else:
|
||||
LOGGER.info(f"Latest version is already installed: {current_version}")
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 2
|
||||
LOGGER.error(f"Exception while running update-check.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running update-check.py :\n{e}")
|
||||
|
||||
sys_exit(status)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from os import getenv, sep
|
|||
from os.path import join
|
||||
from pathlib import Path
|
||||
from sys import exit as sys_exit, path as sys_path
|
||||
from traceback import format_exc
|
||||
|
||||
for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in (("deps", "python"), ("utils",), ("api",), ("db",))]:
|
||||
if deps_path not in sys_path:
|
||||
|
|
@ -50,8 +49,8 @@ try:
|
|||
root_dir = Path(sep, "var", "tmp", "bunkerweb", "lets-encrypt", ".well-known", "acme-challenge")
|
||||
root_dir.mkdir(parents=True, exist_ok=True)
|
||||
root_dir.joinpath(token).write_text(validation, encoding="utf-8")
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 1
|
||||
LOGGER.error(f"Exception while running certbot-auth.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running certbot-auth.py :\n{e}")
|
||||
|
||||
sys_exit(status)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from os import getenv, sep
|
|||
from os.path import join
|
||||
from pathlib import Path
|
||||
from sys import exit as sys_exit, path as sys_path
|
||||
from traceback import format_exc
|
||||
|
||||
for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in (("deps", "python"), ("utils",), ("api",), ("db",))]:
|
||||
if deps_path not in sys_path:
|
||||
|
|
@ -45,8 +44,8 @@ try:
|
|||
# Linux case
|
||||
else:
|
||||
Path(sep, "var", "tmp", "bunkerweb", "lets-encrypt", ".well-known", "acme-challenge", token).unlink(missing_ok=True)
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 1
|
||||
LOGGER.error(f"Exception while running certbot-cleanup.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running certbot-cleanup.py :\n{e}")
|
||||
|
||||
sys_exit(status)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ from os import getenv, sep
|
|||
from os.path import join
|
||||
from sys import exit as sys_exit, path as sys_path
|
||||
from tarfile import open as tar_open
|
||||
from traceback import format_exc
|
||||
|
||||
for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in (("deps", "python"), ("utils",), ("api",), ("db",))]:
|
||||
if deps_path not in sys_path:
|
||||
|
|
@ -70,8 +69,8 @@ try:
|
|||
LOGGER.error(f"Error while sending API request to {api.endpoint}/reload : status = {resp['status']}, msg = {resp['msg']}")
|
||||
else:
|
||||
LOGGER.info(f"Successfully sent API request to {api.endpoint}/reload")
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 1
|
||||
LOGGER.error(f"Exception while running certbot-deploy.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running certbot-deploy.py :\n{e}")
|
||||
|
||||
sys_exit(status)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ from pathlib import Path
|
|||
from shutil import rmtree
|
||||
from subprocess import DEVNULL, STDOUT, Popen, run, PIPE
|
||||
from sys import exit as sys_exit, path as sys_path
|
||||
from traceback import format_exc
|
||||
from re import MULTILINE, search
|
||||
|
||||
for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in (("deps", "python"), ("utils",), ("db",))]:
|
||||
|
|
@ -196,8 +195,8 @@ try:
|
|||
LOGGER.info("Successfully saved Let's Encrypt data to db cache")
|
||||
except SystemExit as e:
|
||||
status = e.code
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 3
|
||||
LOGGER.error(f"Exception while running certbot-new.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running certbot-new.py :\n{e}")
|
||||
|
||||
sys_exit(status)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ from os.path import join
|
|||
from pathlib import Path
|
||||
from subprocess import DEVNULL, PIPE, Popen
|
||||
from sys import exit as sys_exit, path as sys_path
|
||||
from traceback import format_exc
|
||||
|
||||
for deps_path in [
|
||||
join(sep, "usr", "share", "bunkerweb", *paths)
|
||||
|
|
@ -83,8 +82,8 @@ try:
|
|||
LOGGER.info("Successfully saved Let's Encrypt data to db cache")
|
||||
except SystemExit as e:
|
||||
status = e.code
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 2
|
||||
LOGGER.error(f"Exception while running certbot-renew.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running certbot-renew.py :\n{e}")
|
||||
|
||||
sys_exit(status)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ from os import getenv, sep
|
|||
from os.path import join
|
||||
from re import compile as re_compile
|
||||
from sys import exit as sys_exit, path as sys_path, version
|
||||
from traceback import format_exc
|
||||
from typing import Any, Dict
|
||||
|
||||
for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in (("deps", "python"), ("utils",), ("db",))]:
|
||||
|
|
@ -116,8 +115,8 @@ try:
|
|||
status = 2
|
||||
except SystemExit as e:
|
||||
status = e.code
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 2
|
||||
LOGGER.error(f"Exception while running anonymous-report.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running anonymous-report.py :\n{e}")
|
||||
|
||||
sys_exit(status)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ from os.path import join
|
|||
from pathlib import Path
|
||||
from subprocess import DEVNULL, run
|
||||
from sys import exit as sys_exit, path as sys_path
|
||||
from traceback import format_exc
|
||||
|
||||
for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in (("deps", "python"), ("utils",), ("db",))]:
|
||||
if deps_path not in sys_path:
|
||||
|
|
@ -71,8 +70,8 @@ try:
|
|||
LOGGER.info("Successfully saved default-server-cert default-server-cert.key file to db cache")
|
||||
else:
|
||||
LOGGER.info("Skipping generation of self-signed certificate for default server (already present)")
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 2
|
||||
LOGGER.error(f"Exception while running default-server-cert.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running default-server-cert.py :\n{e}")
|
||||
|
||||
sys_exit(status)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ from uuid import uuid4
|
|||
from json import JSONDecodeError, load as json_load, loads
|
||||
from shutil import copytree, rmtree
|
||||
from tarfile import open as tar_open
|
||||
from traceback import format_exc
|
||||
from zipfile import ZipFile
|
||||
|
||||
for deps_path in [
|
||||
|
|
@ -117,8 +116,8 @@ try:
|
|||
for chunk in resp.iter_content(chunk_size=8192):
|
||||
if chunk:
|
||||
content += chunk
|
||||
except:
|
||||
LOGGER.error(f"Exception while downloading plugin(s) from {plugin_url} :\n{format_exc()}")
|
||||
except BaseException as e:
|
||||
LOGGER.error(f"Exception while downloading plugin(s) from {plugin_url} :\n{e}")
|
||||
status = 2
|
||||
continue
|
||||
|
||||
|
|
@ -146,8 +145,8 @@ try:
|
|||
else:
|
||||
LOGGER.error(f"Unknown file type for {plugin_url}, either zip or tar are supported, skipping...")
|
||||
continue
|
||||
except:
|
||||
LOGGER.error(f"Exception while decompressing plugin(s) from {plugin_url} :\n{format_exc()}")
|
||||
except BaseException as e:
|
||||
LOGGER.error(f"Exception while decompressing plugin(s) from {plugin_url} :\n{e}")
|
||||
status = 2
|
||||
continue
|
||||
|
||||
|
|
@ -159,8 +158,8 @@ try:
|
|||
plugin_nbr += 1
|
||||
except FileExistsError:
|
||||
LOGGER.warning(f"Skipping installation of plugin {plugin_path.parent.name} (already installed)")
|
||||
except:
|
||||
LOGGER.error(f"Exception while installing plugin(s) from {plugin_url} :\n{format_exc()}")
|
||||
except BaseException as e:
|
||||
LOGGER.error(f"Exception while installing plugin(s) from {plugin_url} :\n{e}")
|
||||
status = 2
|
||||
|
||||
if not plugin_nbr:
|
||||
|
|
@ -211,9 +210,9 @@ try:
|
|||
|
||||
except SystemExit as e:
|
||||
status = e.code
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 2
|
||||
LOGGER.error(f"Exception while running download-plugins.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running download-plugins.py :\n{e}")
|
||||
|
||||
rmtree(TMP_DIR, ignore_errors=True)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ from re import MULTILINE, search
|
|||
from shutil import rmtree
|
||||
from sys import exit as sys_exit, path as sys_path
|
||||
from tarfile import open as tar_open
|
||||
from traceback import format_exc
|
||||
|
||||
for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in (("deps", "python"), ("utils",), ("db",))]:
|
||||
if deps_path not in sys_path:
|
||||
|
|
@ -119,8 +118,8 @@ try:
|
|||
status = 1
|
||||
except SystemExit as e:
|
||||
status = e.code
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 2
|
||||
LOGGER.error(f"Exception while running coreruleset-nightly.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running coreruleset-nightly.py :\n{e}")
|
||||
|
||||
sys_exit(status)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ from uuid import uuid4
|
|||
from json import dumps
|
||||
from shutil import copy, copytree, move, rmtree
|
||||
from tarfile import open as tar_open
|
||||
from traceback import format_exc
|
||||
from zipfile import ZipFile
|
||||
|
||||
for deps_path in [
|
||||
|
|
@ -230,9 +229,9 @@ try:
|
|||
status = 1
|
||||
except SystemExit as e:
|
||||
status = e.code
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 2
|
||||
LOGGER.error(f"Exception while running download-crs-plugins.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running download-crs-plugins.py :\n{e}")
|
||||
|
||||
rmtree(TMP_DIR, ignore_errors=True)
|
||||
rmtree(NEW_PLUGINS_DIR, ignore_errors=True)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ from uuid import uuid4
|
|||
from json import JSONDecodeError, load as json_load, loads
|
||||
from shutil import copytree, rmtree
|
||||
from tarfile import open as tar_open
|
||||
from traceback import format_exc
|
||||
from zipfile import ZipFile
|
||||
|
||||
for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in (("deps", "python"), ("utils",), ("api",), ("db",))]:
|
||||
|
|
@ -319,9 +318,9 @@ try:
|
|||
LOGGER.info("🚀 Pro plugins downloaded and installed successfully!")
|
||||
except SystemExit as e:
|
||||
status = e.code
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 2
|
||||
LOGGER.error(f"Exception while running download-pro-plugins.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running download-pro-plugins.py :\n{e}")
|
||||
|
||||
for plugin_tmp in TMP_DIR.glob("*"):
|
||||
rmtree(plugin_tmp, ignore_errors=True)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ from os.path import join
|
|||
from pathlib import Path
|
||||
from subprocess import DEVNULL, run
|
||||
from sys import exit as sys_exit, path as sys_path
|
||||
from traceback import format_exc
|
||||
from typing import Tuple
|
||||
|
||||
for deps_path in [join(sep, "usr", "share", "bunkerweb", *paths) for paths in (("deps", "python"), ("utils",), ("db",))]:
|
||||
|
|
@ -149,8 +148,8 @@ try:
|
|||
JOB.del_cache("key.pem", service_id=first_server)
|
||||
except SystemExit as e:
|
||||
status = e.code
|
||||
except:
|
||||
except BaseException as e:
|
||||
status = 2
|
||||
LOGGER.error(f"Exception while running self-signed.py :\n{format_exc()}")
|
||||
LOGGER.error(f"Exception while running self-signed.py :\n{e}")
|
||||
|
||||
sys_exit(status)
|
||||
|
|
|
|||
Loading…
Reference in a new issue