2. Set up Gearman / TheSchwartz

The workers all live in bin/worker/*. There should be gearmand - the main executable for the Gearman server, TheSchwartz DB, and at least one copy of each worker running, in order to get full functionality from the LiveJournal application. The filename for each worker gives you an idea what it does. If you have disabled a particular feature in ljconfig.pl, it generally follows you do not need to start that particular worker.

Setting up Gearman First, make sure the necessary directories are in place.

# mkdir /var/run/gearman

Next, create the configuration file for the workers.

$ touch $LJHOME/cgi-bin/workers.conf
$ nano $LJHOME/cgi-bin/workers.conf

Enter tasks for the workers in the file you just created, using the following format: hostname / jobname = num_to_run. The output of hostname needs to match the value in workers.conf, so the search-updater worker works correctly. For example:

localhost / process-esn = 1
localhost / process-sms = 1
localhost / send-email  = 1

You need to configure gearmand servers in ljconfig.pl, so you can run workers. It is a good idea to set particular features to use Gearman at the same time.

@LJ::GEARMAN_SERVERS
('foo.example.com:7003')
$LJ::LOADTAGS_USING_GEARMAN =1;
$LJ::LOADFRIENDS_USING_GEARMAN =1;
$LJ::LOADSYSBAN_USING_GEARMAN =1;

Last, start up the worker processes, in $LJHOME/bin/worker.

Setting up TheSchwartz First, configure ljconfig.pl so TheSchwartz can connect to your database:

my $mast = $LJ::DBINFO{master};
        my $dbname = $mast->{dbname} || "livejournal";
        @LJ::THESCHWARTZ_DBS = ({
            dsn  => "dbi:mysql:$dbname;host=$mast->{host}",
            user => $mast->{user},
            pass => $mast->{pass},
            prefix => "sch_",
        });

The database tables are created for you “automatically”, by the update-db.pl tool.

Now start up TheSchwartz worker processes from bin/worker/. To use the workers you can start them from a shell script, or manually at a command prompt. If you want to use TheSchwartz for incoming e-mail create a file named .forward in your $LJHOME directory to pipe into incoming-mail-inject.pl:

|/home/lj/bin/incoming-mail-inject.pl

Tip

To make worker processes run in the background, add a Unix switch to the command:

bin/worker/process-esn &