Sphinx::Control - Simple class to manage a Sphinx searchd
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';
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.
This is a Path::Class::File instance for the configuration file.
This is a Path::Class::File instance pointing to the searchd binary. This can be autodiscovered or you can specify it via the constructor.
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.
Starts the Sphinx searchd deamon that is currently being controlled by this instance. It will also run the pre_startup and post_startup hooks.
Stops the Sphinx searchd deamon that is currently being controlled by this instance. It will also run the pre_shutdown and post_shutdown hooks.
Stops and thens starts the searchd daemon.
Sends a HUP signal to the searchd daemon if it is running, to tell it to reload its databases; otherwise starts searchd.
This is the PID of the live server.
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).
$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.
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
depends on $ctl->verbose.
<fayland at gmail.com>
Copyright 2008 Fayland Lam
except for those parts that are
Copyright 2008 Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.