diff --git a/.env.prod b/.env.prod index 969758dc8b3d4f5af784e8eab158bcf7d1ad9d4b..f03eda549789756ec18d54d13b4eb1e5fb0eb4e4 100644 --- a/.env.prod +++ b/.env.prod @@ -15,3 +15,6 @@ MORTY_PORT=8089 INTERNAL_NETWORK_NAME=default NODE_NAME=spot11 CI_REGISTRY_IMAGE=image +SENTRY_DSN=public_key:gitlab.com +SENTRY_TRACES_SAMPLE_RATE=1.0 +ENVIRONMENT_NAME=prod diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2852d4abd613c79dd8775bb5d9ef67f0cc6ac307..4dee0116230228d4d88da2dc59c7fe27431443a1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -114,6 +114,9 @@ deploy:spot.eeo.one.backend1: && sed -i 's/MORTY_PORT=8089/MORTY_PORT=$MORTY_PORT/g' .env && sed -i 's/INTERNAL_NETWORK_NAME=default/INTERNAL_NETWORK_NAME=$INTERNAL_NETWORK_NAME/g' .env && sed -i 's/NODE_NAME=spot11/NODE_NAME=$NODE_NAME/g' .env + && sed -i 's/ENVIRONMENT_NAME=prod/ENVIRONMENT_NAME=$ENVIRONMENT_NAME/g' .env + && sed -i 's|SENTRY_DSN=public_key:gitlab.com|SENTRY_DSN=$SENTRY_DSN|g' .env + && sed -i 's|SENTRY_TRACES_SAMPLE_RATE=1.0|SENTRY_TRACES_SAMPLE_RATE=$SENTRY_TRACES_SAMPLE_RATE|g' .env && sed -i 's|CI_REGISTRY_IMAGE=image|CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE|g' .env && docker-compose pull && docker-compose stop filtron && sleep 2 && docker-compose up -d" @@ -157,6 +160,9 @@ deploy:spot.eeo.one.backend2: && sed -i 's/MORTY_PORT=8089/MORTY_PORT=$MORTY_PORT/g' .env && sed -i 's/INTERNAL_NETWORK_NAME=default/INTERNAL_NETWORK_NAME=$INTERNAL_NETWORK_NAME/g' .env && sed -i 's/NODE_NAME=spot11/NODE_NAME=$NODE_NAME/g' .env + && sed -i 's/ENVIRONMENT_NAME=prod/ENVIRONMENT_NAME=$ENVIRONMENT_NAME/g' .env + && sed -i 's|SENTRY_DSN=public_key:gitlab.com|SENTRY_DSN=$SENTRY_DSN|g' .env + && sed -i 's|SENTRY_TRACES_SAMPLE_RATE=1.0|SENTRY_TRACES_SAMPLE_RATE=$SENTRY_TRACES_SAMPLE_RATE|g' .env && sed -i 's|CI_REGISTRY_IMAGE=image|CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE|g' .env && docker-compose pull && docker-compose stop filtron && sleep 5 && docker-compose up -d" @@ -199,6 +205,9 @@ deploy:spot.ecloud.global.backend1: && sed -i 's/MORTY_PORT=8089/MORTY_PORT=$MORTY_PORT/g' .env && sed -i 's/INTERNAL_NETWORK_NAME=default/INTERNAL_NETWORK_NAME=$INTERNAL_NETWORK_NAME/g' .env && sed -i 's/NODE_NAME=spot11/NODE_NAME=$NODE_NAME/g' .env + && sed -i 's/ENVIRONMENT_NAME=prod/ENVIRONMENT_NAME=$ENVIRONMENT_NAME/g' .env + && sed -i 's|SENTRY_DSN=public_key:gitlab.com|SENTRY_DSN=$SENTRY_DSN|g' .env + && sed -i 's|SENTRY_TRACES_SAMPLE_RATE=1.0|SENTRY_TRACES_SAMPLE_RATE=$SENTRY_TRACES_SAMPLE_RATE|g' .env && sed -i 's|CI_REGISTRY_IMAGE=image|CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE|g' .env && docker-compose pull && docker-compose stop filtron && sleep 2 && docker-compose up -d" @@ -241,6 +250,9 @@ deploy:spot.ecloud.global.backend2: && sed -i 's/MORTY_PORT=8089/MORTY_PORT=$MORTY_PORT/g' .env && sed -i 's/INTERNAL_NETWORK_NAME=default/INTERNAL_NETWORK_NAME=$INTERNAL_NETWORK_NAME/g' .env && sed -i 's/NODE_NAME=spot11/NODE_NAME=$NODE_NAME/g' .env + && sed -i 's/ENVIRONMENT_NAME=prod/ENVIRONMENT_NAME=$ENVIRONMENT_NAME/g' .env + && sed -i 's|SENTRY_DSN=public_key:gitlab.com|SENTRY_DSN=$SENTRY_DSN|g' .env + && sed -i 's|SENTRY_TRACES_SAMPLE_RATE=1.0|SENTRY_TRACES_SAMPLE_RATE=$SENTRY_TRACES_SAMPLE_RATE|g' .env && sed -i 's|CI_REGISTRY_IMAGE=image|CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE|g' .env && docker-compose pull && docker-compose stop filtron && sleep 2 && docker-compose up -d" diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index e4d82b3a4908c301b6eee347dcc7569e917b1959..2561145bf94fa859b110a48a822a2007d36a8a81 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -37,6 +37,9 @@ services: GUNICORN_LOGGER: 1 GUNICORN_LEVEL: INFO NODE_NAME: "${NODE_NAME}" + SENTRY_DSN: "${SENTRY_DSN}" + SENTRY_TRACES_SAMPLE_RATE: "${SENTRY_TRACES_SAMPLE_RATE}" + ENVIRONMENT_NAME: "${ENVIRONMENT_NAME}" spot-nginx: image: ${CI_REGISTRY_IMAGE}/nginx:${SPOT_NGINX_DOCKER_TAG} diff --git a/requirements.txt b/requirements.txt index 31f48c2691c6f5a32ea4825df28b322b897ff31d..f0f31bdc5f0b26aa6d3ded5adc4629e82fabd3de 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,7 @@ babel==2.9.1 flask-babel==2.0.0 flask==2.0.2 jinja2==3.0.3 +sentry-sdk[flask]==1.5.9 lxml==4.7.1 pygments==2.8.0 python-dateutil==2.8.2 diff --git a/searx/webapp.py b/searx/webapp.py index 4ad9072474de4f126593b23ae4817858f6b8d2ae..d0b13ead599b7ef6363afcc5e27dc27438a2d1d0 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -103,6 +103,31 @@ from searx.settings_loader import get_default_settings_path from werkzeug.serving import WSGIRequestHandler WSGIRequestHandler.protocol_version = "HTTP/{}".format(settings['server'].get('http_protocol_version', '1.0')) + +# Enable sentry only if SENTRY_DSN variable is set +if os.getenv('SENTRY_DSN', None) is not None: + import sentry_sdk + from sentry_sdk.integrations.flask import FlaskIntegration + + sentry_sdk.init( + dsn=os.getenv("SENTRY_DSN"), + integrations=[FlaskIntegration()], + environment=os.getenv("ENVIRONMENT_NAME"), + server_name=os.getenv("ENVIRONMENT_NAME"), + + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for performance monitoring. + # We recommend adjusting this value in production. + traces_sample_rate=float(os.getenv("SENTRY_TRACES_SAMPLE_RATE", 1.0)), + + # By default the SDK will try to use the SENTRY_RELEASE + # environment variable, or infer a git commit + # SHA as release, however you may want to set + # something more human-readable. + release="spot@{}".format(os.getenv("ENVIRONMENT_NAME")), + ) + + # check secret_key if not searx_debug and settings['server']['secret_key'] == 'ultrasecretkey': logger.error('server.secret_key is not changed. Please use something else instead of ultrasecretkey.') diff --git a/setup.py b/setup.py index e7e42179747bf57395d7cb63cad6b4b5a3cdaf87..97e0e5d01cf0de8c3ca9442cb2e6883a05c4726c 100644 --- a/setup.py +++ b/setup.py @@ -1,18 +1,30 @@ # -*- coding: utf-8 -*- -"""Installer for Searx package.""" +"""Installer for Spot package.""" from setuptools import setup from setuptools import find_packages +from searx.version import VERSION_STRING +from searx import brand +with open('README.md', encoding='utf-8') as f: + long_description = f.read() -requirements = open('requirements.txt').read().splitlines() -dev_requirements = open('requirements-dev.txt').read().splitlines() +with open('requirements.txt') as f: + requirements = [ l.strip() for l in f.readlines()] + +with open('requirements-dev.txt') as f: + dev_requirements = [ l.strip() for l in f.readlines()] setup( - name='searx', - use_scm_version={"tag_regex": r"^(?:[\w-]+-)?(?P[vV]?\d+(?:\.\d+){0,2}.*)$"}, + name='spot', + version=VERSION_STRING, description="A privacy-respecting, hackable metasearch engine", - long_description=open('README.md').read(), + long_description=long_description, + url=brand.DOCS_URL, + project_urls={ + "Code": brand.GIT_URL, + "Issue tracker": brand.ISSUE_URL + }, classifiers=[ "Development Status :: 4 - Beta", "Programming Language :: Python", @@ -22,13 +34,12 @@ setup( 'License :: OSI Approved :: GNU Affero General Public License v3' ], keywords='metasearch searchengine search web http', - author='Adam Tauber', - author_email='asciimoo@gmail.com', + author='E FOUNDATION', + author_email='dev@e.email', license='GNU Affero General Public License', packages=find_packages(exclude=["tests*", "searx_extra"]), zip_safe=False, install_requires=requirements, - setup_requires=["setuptools_scm"], extras_require={ 'test': dev_requirements }, @@ -41,6 +52,9 @@ setup( package_data={ 'searx': [ 'settings.yml', + '../README.md', + '../requirements.txt', + '../requirements-dev.txt', 'data/*', 'plugins/*/*', 'static/*.*',