The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Sphinx::Manager - Sphinx search engine management (start/stop)

VERSION

Version 0.01

SYNOPSIS

    use Sphinx::Manager;

    my $mgr = Sphinx::Manager->new({ config_file => '/etc/sphinx.conf' });
    $mgr->start_searchd;
    $mgr->restart_searchd;
    $mgr->reload_searchd;
    $mgr->stop_searchd;
    $mgr->get_searchd_pid;
    $mgr->run_indexer;

DESCRIPTION

This module provides utilities to start, stop, restart, and reload the Sphinx search engine binary (searchd), and to run the Sphinx indexer program. The utilities are designed to handle abnormal conditions, such as PID files not being present when expected, and so should be robust in most situations.

CONSTRUCTOR

new

    $mgr = Sphinx::Manager->new(\%opts);

Create a new Sphinx manager. The names of options are the same as the setter/getter functions listed below.

SETTERS/GETTERS

config_file

    $mgr->config_file($filename)
    $filename = $mgr->config_file;

Set/get the configuration file. Defaults to sphinx.conf in current working directory.

pid_file

    $mgr->pid_file($filename)
    $filename = $mgr->pid_file;

Set/get the PID file. If given, this will be used in preference to any value in the given config_file.

bindir

    $mgr->bindir($dir)
    $dir = $mgr->bindir;

Set/get the directory in which to find the Sphinx binaries.

debug

    $mgr->debug(1);
    $mgr->debug(0);
    $debug_state = $mgr->debug;

Enable/disable debugging messages, or read back debug status.

process_timeout

    $mgr->process_timeout($secs)
    $secs = $mgr->process_timeout;

Set/get the time (in seconds) to wait for processes to start or stop.

searchd_args

    $mgr->searchd_args(\@args)
    $args = $mgr->searchd_args;

Set/get the extra command line arguments to pass to searchd when started using start_searchd. 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.

METHODS

start_searchd

    $mgr->start_searchd;

Starts the Sphinx searchd daemon. Dies if searchd cannot be started or if it is already running.

stop_searchd

    $mgr->stop_searchd;

Stops Sphinx searchd daemon. Dies if searchd cannot be stopped.

restart_searchd

    $mgr->restart_searchd;

Stops and thens starts the searchd daemon.

reload_searchd

    $mgr->reload_searchd;

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

get_searchd_pid

    $pids = $mgr->get_searchd_pid;

Returns an array ref containing the PID(s) of the searchd daemon. If the PID file is in place and searchd is running, then an array containing a single PID is returned. If the PID file is not present or is empty, the process table is checked for other searchd processes running with the specified config file; if found, all are returned in the array.

indexer_args

    $mgr->indexer_args(\@args)
    $args = $mgr->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.

CAVEATS

This module has been tested primarily on Linux. It should work on any other operating systems where fork() is supported and Proc::ProcessTable works.

SEE ALSO

Sphinx::Search, Sphinx::Config

AUTHOR

Jon Schutz, http://notes.jschutz.net

BUGS

Please report any bugs or feature requests to bug-sphinx-config at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sphinx-Manager. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Sphinx::Manager

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2008 Jon Schutz, all rights reserved.

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