Skip to content

Instantly share code, notes, and snippets.

@jalaziz
Created August 14, 2014 02:25
Show Gist options
  • Save jalaziz/55de1a30400dadf3152b to your computer and use it in GitHub Desktop.
Save jalaziz/55de1a30400dadf3152b to your computer and use it in GitHub Desktop.

Revisions

  1. jalaziz created this gist Aug 14, 2014.
    30 changes: 30 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    Setup
    =====

    1. Create a new user on the system:

    ```shell
    sudo adduser --system --group --shell /bin/bash --home /opt/sentry sentry
    ```

    3. Create the virualenv and install the required packages:

    ```shell
    sudo -u sentry virtualenv /opt/sentry
    sudo -u sentry /opt/sentry/bin/pip install sentry
    ```

    4. Place the upstart configs in `/etc/init`.
    5. Place the nginx config in `/etc/nginx/sites-available`. Then symlink to `/etc/nginx/sites-enabled`.
    6. Initialize sentry (run as the `sentry` user):

    ```shell
    cd /opt/sentry
    source bin/activate
    sentry init /opt/sentry/sentry.conf.py
    vi /opt/sentry/sentry.conf.py # Edit the sentry configuration
    export SENTRY_CONF=/opt/sentry/sentry.conf.py
    sentry upgrade
    sentry createsuperuser
    sentry repair --owner=<superuser>
    ```
    14 changes: 14 additions & 0 deletions sentry-celery.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    description "Sentry Celery"

    start on started sentry
    stop on stopping sentry

    respawn limit 10 5
    chdir /opt/sentry
    setuid sentry

    env VIRTUAL_ENV=/opt/sentry/
    env PYTHONUNBUFFERED=True
    env SENTRY_CONF=/opt/sentry/sentry.conf.py

    exec $VIRTUAL_ENV/bin/sentry celery worker -B --loglevel=info >> /var/log/sentry/celery.log 2>&1
    14 changes: 14 additions & 0 deletions sentry-web.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    description "Sentry Web"

    start on started sentry
    stop on stopping sentry

    respawn limit 10 5
    chdir /opt/sentry
    setuid sentry

    env VIRTUAL_ENV=/opt/sentry/
    env PYTHONUNBUFFERED=True
    env SENTRY_CONF=/opt/sentry/sentry.conf.py

    exec $VIRTUAL_ENV/bin/sentry start >> /var/log/sentry/web.log 2>&1
    9 changes: 9 additions & 0 deletions sentry.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    description "Sentry"

    pre-start script
    mkdir -p /var/log/sentry
    chown -R sentry /var/log/sentry
    end script

    start on runlevel [2345]
    stop on runlevel [016]
    47 changes: 47 additions & 0 deletions sentry.nginx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    # we limit both on IP (single machine) as well as project ID
    limit_req_zone $binary_remote_addr zone=sentry1:10m rate=3r/s;
    limit_req_zone $projectid zone=sentry2:10m rate=3r/s;

    server {
    listen 80;
    server_name sentry.example.com;

    # limit_req_status requires nginx 1.3.15 or newer
    limit_req_status 429;

    charset utf-8;

    access_log /var/log/nginx/sentry.access.log;
    error_log /var/log/nginx/sentry.error.log;

    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_redirect off;

    # keepalive + raven.js is a disaster
    keepalive_timeout 0;

    # use very aggressive timeouts
    proxy_read_timeout 5s;
    proxy_send_timeout 5s;
    send_timeout 5s;
    resolver_timeout 5s;
    client_body_timeout 5s;

    # buffer larger messages
    client_max_body_size 150k;
    client_body_buffer_size 150k;

    location / {
    proxy_pass http://localhost:9000;
    }

    location ~* /api/(?P<projectid>\d+/)?store/ {
    proxy_pass http://localhost:9000;

    limit_req zone=sentry1 burst=3 nodelay;
    limit_req zone=sentry2 burst=10 nodelay;
    }
    }