npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-sphinx

v0.1.0

Published

Control sphinx search from grunt and grunt watch

Downloads

6

Readme

grunt-sphinx

Start your sphinx search server from grunt

Getting Started

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

Tasks

There are two tasks that you can use in your Gruntfile:

'sphinx-indexer'

and

'sphinx-searchd'

Each needs configuration from within the Gruntfile. You must specify the path to your sphinx.conf file, as well as the path to the pid file for sphinxd. The pid_file path in the config must match the path specified in searchd block of your sphinx.conf. Here's my example setup.

Setup

  grunt.initConfig({
    'sphinx-searchd': {
      //customize options here
      options: { 
        conf_file : 'sphinx.conf',            //REQUIRED
        pid_file : 'sphinx/logs/searchd.pid', //REQUIRED
        cmd : 'sphinx-searchd',               //REQUIRED
        debug : false,
        args : [], //any additional args to pass to the searchd command
        watch_delay : 200, //only required if used with the grunt watch task
      },
    },
    'sphinx-indexer': {
      //customize options here
      options: { 
        conf_file : 'sphinx.conf',         // REQUIRED
        cmd : 'sphinx-indexer',            // REQUIRED
        indeces: [ '--all' ],              // REQUIRED
        debug : false,
        args : [], //any additional args to pass to the indexer command
      }
    }
  });

Once the plugin has been installed and configured, enable it inside your Gruntfile:

grunt.loadNpmTasks('grunt-sphinx');

Options

The options should be easily inferred from looking at the example Gruntfile config above. Any valid command-line arguments can be passed to either the searchd or indexer command by means of the 'args' option in the config block. The arguments must be listed as elements in the array.

I'd be happy to add more options, such as a callback once the searchd command or indexer have completed, just submit an issue request.

Stopping and starting the searchd server

The searchd server typically runs as a background process, but can be easily stopped and started from within grunt, as stop and start are registered tasks.

$> grunt sphinx-searchd:stop
$> grunt sphinx-searchd:start

With grunt-contrib-watch

grunt.initConfig({
  watch: {
    sphinx: {
      files:  [ 'sphinx.conf' ],
      tasks:  [ 'sphinx-searchd', 'sphinx-indexer' ],
      options: {
        spawn : false, // IMPORTANT. Will not work without this.
      }
    }
  }
});

grunt.registerTask('server', [ 'sphinx-indexer', 'sphinx-searchd', 'watch' ]);