The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Sphinx::Control - Simple class to manage a Sphinx searchd

SYNOPSIS

    use Sphinx::Control;
    
    my ($command) = @ARGV;
    
    my $ctl = Sphinx::Control->new(
        config_file => [qw[ conf sphinx.conf ]],
        # PID file can also be discovered automatically 
        # from the conf, or if you prefer you can specify
        pid_file    => 'searchd.pid',    
    );
  
    $ctl->start if lc($command) eq 'start';
    $ctl->stop  if lc($command) eq 'stop';

DESCRIPTION

This is a fork of Lighttpd::Control to work with Sphinx searchd, it maintains 100% API compatibility. In fact most of this documentation was stolen too. This is an early release with only the bare bones functionality needed, future releases will surely include more functionality. Suggestions and crazy ideas welcomed, especially in the form of patches with tests.

ATTRIBUTES

config_file

This is a Path::Class::File instance for the configuration file.

binary_path

This is a Path::Class::File instance pointing to the searchd binary. This can be autodiscovered or you can specify it via the constructor.

pid_file

This is a Path::Class::File instance pointing to the searchd pid file. This can be autodiscovered from the config file or you can specify it via the constructor.

METHODS

start

Starts the Sphinx searchd deamon that is currently being controlled by this instance. It will also run the pre_startup and post_startup hooks.

stop

Stops the Sphinx searchd deamon that is currently being controlled by this instance. It will also run the pre_shutdown and post_shutdown hooks.

restart

Stops and thens starts the searchd daemon.

reload

Sends a HUP signal to the searchd daemon if it is running, to tell it to reload its databases; otherwise starts searchd.

get_server_pid

This is the PID of the live server.

is_server_running

Checks to see if the Sphinx searchd deamon that is currently being controlled by this instance is running or not (based on the state of the PID file).

indexer_args
    $ctl->indexer_args(\@args)
    $args = $ctl->indexer_args;

Set/get the extra command line arguments to pass to the indexer program when started using run_indexer. These should be in the form of an array, each entry comprising one option or option argument. Arguments should exclude '--config CONFIG_FILE', which is included on the command line by default.

run_indexer(@args)

Runs the indexer program; dies on error. Arguments passed to the indexer are "--config CONFIG_FILE" followed by args set through indexer_args, followed by any additional args given as parameters to run_indexer.

Copied from Sphinx::Manager

debug

depends on $ctl->verbose.

SEE ALSO

MooseX::Control, Sphinx::Manager, Lighttpd::Control, Nginx::Control, Perlbal::Control

AUTHOR

Fayland Lam, <fayland at gmail.com>

COPYRIGHT & LICENSE

Copyright 2008 Fayland Lam

except for those parts that are

Copyright 2008 Infinity Interactive, Inc.

http://www.iinteractive.com

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.