### Set Up and Activate Virtual Environment Source: https://www.bugsink.com/docs/local-install-using-virtualenv Creates a Python virtual environment named '.' within the current directory and activates it. This isolates project dependencies. The prompt will change to indicate activation. ```bash python -m venv . source bin/activate ``` -------------------------------- ### Verify Database Creation Source: https://www.bugsink.com/docs/local-install-using-virtualenv Checks for the presence of the SQLite database file created by the migration command. This confirms that the database initialization was successful. ```bash ls db.sqlite3 ``` -------------------------------- ### Enable and Start Snappea Service Source: https://www.bugsink.com/docs/single-server-production Commands to enable the Snappea systemd service to start on boot and immediately start the service. These commands require root privileges. ```bash systemctl enable --now snappea.service ``` -------------------------------- ### Install and Run Bugsink with Docker (Quick Instance) Source: https://www.bugsink.com/docs/docker-install This snippet demonstrates how to pull the latest Bugsink Docker image and run a quick, throw-away instance using SQLite as the database. It configures essential environment variables like SECRET_KEY, CREATE_SUPERUSER, and PORT, and maps the container's port to the host. Data is not persisted in this setup. ```docker docker pull bugsink/bugsink:latest docker run \ -e SECRET_KEY=g4IugwUN2lNpIDojjYXFqhrkwaGn0RBxFzAspAOryNhPRY98ug \ -e CREATE_SUPERUSER=admin:admin \ -e PORT=8000 \ -p 8000:8000 \ bugsink/bugsink ``` -------------------------------- ### Install Bugsink and Dependencies Source: https://www.bugsink.com/docs/local-install-using-virtualenv Installs or upgrades Bugsink and its required packages using pip. This command ensures you have the latest version and all necessary components. ```bash python -m pip install bugsink --upgrade ``` -------------------------------- ### Verify Venv Installation Source: https://www.bugsink.com/docs/local-install-using-virtualenv Confirms that the Python venv module is installed, which is used for creating virtual environments. This ensures proper isolation of project dependencies. ```python python3 -c "import venv; print('venv is installed')" ``` -------------------------------- ### Verify Python Installation Source: https://www.bugsink.com/docs/local-install-using-virtualenv Checks if Python is installed on the system. This is a prerequisite for installing Bugsink. It outputs the installed Python version. ```bash python --version ``` -------------------------------- ### Verify Bugsink Installation Source: https://www.bugsink.com/docs/local-install-using-virtualenv Checks if Bugsink has been successfully installed by running its version command. This confirms that the installation process was completed without errors. ```bash bugsink-show-version ``` -------------------------------- ### Create and Navigate to Working Directory Source: https://www.bugsink.com/docs/local-install-using-virtualenv Creates a new directory named 'bugsink' and changes the current directory to it. This directory will store the Bugsink code and collected data. ```bash mkdir bugsink cd bugsink ``` -------------------------------- ### Run Bugsink Server with Gunicorn Source: https://www.bugsink.com/docs/local-install-using-virtualenv This command starts the Bugsink server using Gunicorn, binding it to the local address 127.0.0.1 on port 8000. It also directs access log output to standard output. Ensure Gunicorn is installed in your environment. ```bash gunicorn --bind="127.0.0.1:8000" --access-logfile - bugsink.wsgi ``` -------------------------------- ### Install Nginx Source: https://www.bugsink.com/docs/single-server-production Installs the Nginx web server using the apt package manager. This is a prerequisite for serving the Bugsink application. ```bash apt install nginx ``` -------------------------------- ### Verify Pip Installation Source: https://www.bugsink.com/docs/local-install-using-virtualenv Checks if pip, the Python package installer, is installed. Pip is required to install Bugsink and its dependencies. It outputs the installed pip version. ```bash pip3 --version ``` -------------------------------- ### Enable and Start Gunicorn Service Source: https://www.bugsink.com/docs/single-server-production Commands to enable the Gunicorn systemd service, ensuring it starts on boot, and to start it immediately. This is a standard way to manage services on Linux systems using systemd. ```bash systemctl enable --now gunicorn.service ``` -------------------------------- ### Install Certbot for SSL Source: https://www.bugsink.com/docs/single-server-production Installs Certbot, a tool for automating SSL certificate management, using snap packages. It also creates a symbolic link to make the certbot command accessible. ```bash apt install snapd snap install --classic certbot ln -s /snap/bin/certbot /usr/bin/certbot ``` -------------------------------- ### Create Bugsink Superuser Source: https://www.bugsink.com/docs/local-install-using-virtualenv Creates an administrative user account for Bugsink. This user will have full privileges to manage the Bugsink installation through the web interface. ```bash bugsink-manage createsuperuser ``` -------------------------------- ### Docker Installation for Bugsink Source: https://www.bugsink.com/docs/installation Quickly evaluate Bugsink by running a Docker container. This command pulls the latest image and starts a container with essential configurations like a secret key, superuser creation, and port mapping. ```docker docker pull bugsink/bugsink:latest docker run \ -e SECRET_KEY=sms0blJBsUStQy0KwDtFNNoPRQMjM4Z9Rkw4mMr9QIpJNzRGrv \ -e CREATE_SUPERUSER=admin:admin \ -e PORT=8000 \ -p 8000:8000 \ bugsink/bugsink ``` -------------------------------- ### Install PostgreSQL Driver for Python Virtual Environments Source: https://www.bugsink.com/docs/postgresql When installing Bugsink in a Python virtual environment, the `psycopg[binary]` package must be installed manually. This command installs the required package, ensuring compatibility with PostgreSQL version 3 or higher. ```bash pip install "psycopg[binary]" ``` -------------------------------- ### Initialize Bugsink Database Source: https://www.bugsink.com/docs/local-install-using-virtualenv Initializes the Bugsink database using Django's migration system. This creates the necessary tables in an SQLite database file named 'db.sqlite3' in the current directory. ```bash bugsink-manage migrate ``` -------------------------------- ### Install Bugsink Stress Test Tool Source: https://www.bugsink.com/docs/stress-testing Installs the bugsink package, which includes the stress test utility, using pip. This assumes Python, pip, and a virtual environment are already set up. ```bash pip install bugsink ``` -------------------------------- ### Example Bugsink Stress Test Command Source: https://www.bugsink.com/docs/stress-testing An example of running the bugsink stress test with specific options for DSN, requests, threads, and compression. This command sends 1000 events (100 requests * 10 threads) with Brotli compression. ```bash bugsink-manage stress_test sample.json \ --dsn=https://a2f..1a2@yourhost.com/1 \ --requests 100 --threads 10 --compress=br ``` -------------------------------- ### Create Bugsink Configuration File Source: https://www.bugsink.com/docs/single-server-production Generates a default configuration file for a single-server Bugsink installation. Replace 'YOURHOST' with your server's hostname. This command creates a 'bugsink_conf.py' file in the current directory. ```bash bugsink-create-conf --template=singleserver --host=YOURHOST ``` -------------------------------- ### Install verbose_csrf_middleware using pip Source: https://www.bugsink.com/docs/verbose_csrf_middleware This snippet shows the command to install the verbose_csrf_middleware package using pip. It's a direct installation command with no external dependencies mentioned. ```bash pip install verbose_csrf_middleware ``` -------------------------------- ### Install MySQL Client for Python Virtual Environments Source: https://www.bugsink.com/docs/mysql When installing Bugsink in a Python virtual environment, the 'mysqlclient' package must be installed manually using pip. This is necessary as the default SQLite database does not require additional packages. ```bash pip install mysqlclient ``` -------------------------------- ### Configure PostgreSQL Connection String in Docker Source: https://www.bugsink.com/docs/postgresql This snippet shows the format for the PostgreSQL connection string used when running Bugsink in a Docker container. The `psycopg[binary]` package is automatically included in the standard Docker image. ```shell postgresql://user:password@host:port/database_name ``` -------------------------------- ### Obtain SSL Certificate with Certbot Source: https://www.bugsink.com/docs/single-server-production Runs Certbot to obtain an SSL certificate for the Nginx server. It uses the '--nginx' plugin for automatic Nginx configuration and '--no-redirect' to defer HTTP to HTTPS redirection setup. ```bash certbot --nginx --rsa-key-size 4096 --no-redirect ``` -------------------------------- ### Configure PostgreSQL Database Settings in Django Source: https://www.bugsink.com/docs/postgresql This Python code snippet demonstrates how to configure PostgreSQL settings within a Django application's `settings.py` file for Bugsink. It specifies the database engine, name, user, password, host, and port. ```python DATABASES['default'] = { 'ENGINE': 'django.db.backends.postgresql', 'NAME': "...", # the name of your database "USER": "...", # the user to connect as "PASSWORD": "...", # the password to use "HOST": "...", # the host to connect to "PORT": "...", # the port to connect to (usually 5432) } ``` -------------------------------- ### Create Superuser for Bugsink via Docker Exec Source: https://www.bugsink.com/docs/docker-install This command demonstrates how to create a superuser for Bugsink after it has been started with an external database. It uses `docker exec` to run the `createsuperuser` management command inside the running container, passing the necessary database URL. ```docker docker exec -it \ -e DATABASE_URL=mysql://[user]:[password]@[host]/[name] \ [container-id] \ bugsink-manage createsuperuser ``` -------------------------------- ### Check Bugsink Configuration and Migrations Source: https://www.bugsink.com/docs/single-server-production Runs checks to verify the database migrations and the overall deployment configuration. The second command checks the deployment configuration with a WARNING failure level. ```bash bugsink-manage check_migrations bugsink-manage check --deploy --fail-level WARNING ``` -------------------------------- ### Test Snappea Task Processing Source: https://www.bugsink.com/docs/single-server-production This sequence of commands logs in as the 'bugsink' user, activates the virtual environment, and runs a command to add a test task to the Snappea queue. This helps verify that Snappea is functioning correctly and processing tasks. ```bash # log in as bugsink user su - bugsink # activate the virtual environment . venv/bin/activate # run the following command to add a test-task to the queue bugsink-manage checksnappea # exit back to root exit ``` -------------------------------- ### Initialize Bugsink Databases Source: https://www.bugsink.com/docs/single-server-production Initializes the main Bugsink database and the separate 'snappea' message queue database. This command creates SQLite database files in the location specified in the configuration file. ```bash bugsink-manage migrate bugsink-manage migrate snappea --database=snappea ``` -------------------------------- ### Verify Database File Creation Source: https://www.bugsink.com/docs/single-server-production Lists all files ending with '.sqlite3' in the current directory to confirm that the database files were successfully created. ```bash ls *.sqlite3 ``` -------------------------------- ### Create Bugsink Configuration Source: https://www.bugsink.com/docs/local-install-using-virtualenv Generates a local configuration file for Bugsink, suitable for development. It sets the web server port to 8000. The generated file is named 'bugsink_conf.py'. ```bash bugsink-create-conf --template=local --port=8000 ``` -------------------------------- ### Configure Snappea Systemd Service Source: https://www.bugsink.com/docs/single-server-production This systemd service file defines how to run Snappea as a background daemon. It specifies the user, working directory, environment variables, and the command to execute. The service is configured to restart automatically if it fails. ```systemd [Unit] Description=snappea daemon [Service] Restart=always User=bugsink Group=bugsink Environment="PYTHONUNBUFFERED=1" WorkingDirectory=/home/bugsink ExecStart=/home/bugsink/venv/bin/bugsink-runsnappea KillMode=mixed TimeoutStopSec=5 RuntimeMaxSec=1d [Install] WantedBy=multi-user.target ``` -------------------------------- ### Test Gunicorn Socket Connection Source: https://www.bugsink.com/docs/single-server-production A curl command to test if Gunicorn is listening on the specified address and port and responding to requests. It sends a GET request to the login page, simulating a client connection. ```bash curl http://localhost:8000/accounts/login/ --header "Host: YOURHOST" ``` -------------------------------- ### Enable Bugsink Nginx Site Source: https://www.bugsink.com/docs/single-server-production Creates a symbolic link to enable the Bugsink site configuration by linking the file from 'sites-available' to 'sites-enabled'. This tells Nginx to use this configuration. ```bash ln -s /etc/nginx/sites-available/bugsink /etc/nginx/sites-enabled ``` -------------------------------- ### Configure Gunicorn Systemd Service Source: https://www.bugsink.com/docs/single-server-production This configuration file sets up a systemd service for Gunicorn, specifying user, working directory, execution command, and logging. It ensures Gunicorn restarts automatically and is managed by systemd. ```systemd service [Unit] Description=gunicorn daemon After=network.target [Service] Restart=always Type=notify User=bugsink Group=bugsink Environment="PYTHONUNBUFFERED=1" WorkingDirectory=/home/bugsink ExecStart=/home/bugsink/venv/bin/gunicorn \ --bind="127.0.0.1:8000" \ --workers=10 \ --timeout=6 \ --access-logfile - \ --max-requests=1000 \ --max-requests-jitter=100 \ bugsink.wsgi ExecReload=/bin/kill -s HUP $MAINPID KillMode=mixed TimeoutStopSec=5 [Install] WantedBy=multi-user.target ``` -------------------------------- ### Test Nginx Configuration Source: https://www.bugsink.com/docs/single-server-production Tests the Nginx configuration files for syntax errors before restarting the Nginx service. This command should be run after any changes to the Nginx configuration. ```bash service nginx configtest ``` -------------------------------- ### Configure Bugsink Behind HTTPS Proxy (Virtualenv) Source: https://www.bugsink.com/docs/proxy-headers For virtual environment setups, configure Bugsink by editing the `bugsink_conf.py` file. Modify the SECURE_PROXY_SSL_HEADER, SESSION_COOKIE_SECURE, CSRF_COOKIE_SECURE, and USE_X_REAL_IP settings directly within this file. ```python # Example settings in bugsink_conf.py SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') SESSION_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True USE_X_REAL_IP = True ``` -------------------------------- ### Configure Bugsink Behind HTTPS Proxy (Docker) Source: https://www.bugsink.com/docs/proxy-headers For Docker setups, configure Bugsink by setting the BEHIND_HTTPS_PROXY environment variable. This variable should be set to 'True' if Bugsink is behind a reverse proxy serving HTTPS, and 'False' otherwise. It automatically adjusts SECURE_PROXY_SSL_HEADER, SESSION_COOKIE_SECURE, CSRF_COOKIE_SECURE, and USE_X_REAL_IP settings. ```bash BEHIND_HTTPS_PROXY=True ``` -------------------------------- ### Edit Bugsink Configuration File Source: https://www.bugsink.com/docs/single-server-production Opens the generated 'bugsink_conf.py' file using the nano text editor for customization. Key settings to review include BASE_URL, SITE_TITLE, email configurations, and user/team registration options. ```bash nano bugsink_conf.py ``` -------------------------------- ### Run Bugsink Stress Test Source: https://www.bugsink.com/docs/stress-testing Executes the stress test using the bugsink-manage tool. It requires a sample JSON file and accepts various options to configure the test, such as DSN, number of threads, requests per thread, and compression. ```bash bugsink-manage stress_test [options] sample.json ```