self-hosting:request_tracker

Request Tracker on Debian/Ubuntu

I like Best Practical's Request Tracker (RT) because it was relatively straight-forward to install and is incredibly configurable. I set one up at work for tracking requests wherever they may come from, and I have a personal instance set up to track projects I'm working on, or would like to get to.

There were a couple “gotchas” I ran into and I hope this article helps you to avoid the same.

RT's documentation is excellent, but there were many problems I ran into that the provided documentation didn't resolve. One of these were related to running RT on a web server serving other sites, something I couldn't figure out how to do with the RT::Extensions::Nginx plugin.

Because RT's documentation is excellent, this article will focus on configuring FCGI for Nginx, and a hacked-together method to ensure RT is running.

Using uwsgi, I've noticed the web process dies a lot less frequently, and the page load times are much quicker.

Requirements:

  • uwsgi
  • uwsgi-plugin-psgi

Install them with apt.

I also noticed I had to allow www-data to read /opt/rt4/etc/RT_Config.pm

# chgrp www-data /opt/rt4/etc/RT_Config.pm

/etc/uwsgi/appsavailable/rt.ini:

[uwsgi]
plugins = psgi
chmod-socket = 664
uid = www-data
gid = www-data
socket = /var/tmp/uwsgi.sock
psgi = /opt/rt4/sbin/rt-server
processes = 10

Be sure to softlink that to /etc/uwsgi/apps-enabled/.

Here's the relevant snippet from /etc/nginx/sites-available/rt.jrgnsn.net.conf:

server {
        ...
 
        location / {
                uwsgi_pass unix:///var/tmp/uwsgi.sock;
                include uwsgi_params;
                uwsgi_modifier1 5;
        }
}

spawn-fcgi can be used to create the FCGI process that Nginx passes requests to.

This is the command I use to start RT with spawn_fcgi:

spawn-fcgi -U www-data -G www-data -a 127.0.0.1 -p 9000 -- /opt/rt4/sbin/rt-server.fcgi

It works well enough, but I've noticed after a while the process will die and I'd have to run that command agian.

Using this article, I created an init script to help control the RT process(es).

#!/bin/sh
 
RTPATH=/opt/rt4
RTUSER=www-data
 
case $1 in
    start)
        echo "Starting RT:"
        spawn-fcgi -F 3 -U $RTUSER -G $RTUSER -a 127.0.0.1 -p 9000 \
        -- /opt/rt4/sbin/rt-server.fcgi
        echo
        ;;
 
    stop)
        echo "Stopping RT:"
        PIDS=`ps axww | awk '/[r]t-server.fcgi/ { print $1 }'`
        if [ -n "$PIDS" ]
        then
            echo -n kill -TERM $PIDS
            kill $PIDS
            echo
        else
            echo "RT not running"
        fi
        ;;
 
    *)
        echo "Usage: /etc/init.d/rt { stop | start | restart }"
        exit 1
        ;;
esac

Then I added the following to root's crontab:

* * * * * /etc/init.d/rt start >> /var/log/rt-init-script.log 2>&1

This will attempt to start RT every minute, doing nothing if it's already running.

Configuring Nginx is pretty easy. I prefer it to Apache's HTTP server.

server {
    listen 80;
    server_name rt.domain.com;
 
    access_log /var/log/nginx/rt/access.log;
    error_log /var/log/nginx/rt/error.log;
 
    location / {
        fastcgi_param   QUERY_STRING    $query_string;
        fastcgi_param   REQUEST_METHOD  $request_method;
        fastcgi_param   CONTENT_TYPE    $content_type;
        fastcgi_param   CONTENT_LENGTH  $content_length;
 
        fastcgi_param   SCRIPT_NAME     "";
        fastcgi_param   PATH_INFO       $uri;
        fastcgi_param   REQUEST_URI     $request_uri;
        fastcgi_param   DOCUMENT_URI    $document_uri;
        fastcgi_param   DOCUMENT_ROOT   $document_root;
        fastcgi_param   SERVER_PROTOCOL $server_protocol;
 
        fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
        fastcgi_param   SERVER_SOFTWARE nginx;
 
        fastcgi_param   REMOTE_ADDR     $remote_addr;
        fastcgi_param   REMOTE_PORT     $remote_port;
        fastcgi_param   SERVER_ADDR     $server_addr;
        fastcgi_param   SERVER_PORT     $server_port;
        fastcgi_param   SERVER_NAME     $server_name;
        fastcgi_pass    127.0.0.1:9000;
    }
}

NOTE: You'll need to create the following directory otherwise Nginx will throw a fit: /var/log/nginx/rt.

  • self-hosting/request_tracker.txt
  • Last modified: 2019/10/08 17:50
  • by mjorgensen