Mugo Web main content.

Running multiple instances of eZ Find on the same host

By: Doug Plant | July 10, 2012 | eZ Publish development tips

The problem:

By default, 2 instances of eZ Find can not run at the same IP address because eZ Find and Solr communicate with each other via an IP port. This becomes an issue if you happen to run a staging instance on the same server as a production instance, or on your local dev machine where there are many sites running.

A nice solution makes use of the symlinking trick for managing platform-specific versions of settings files I recently documented.

The Specifics:

There are two settings files that need to be managed, and then the init.d script has to be customized as well.

First off, you need to do the symlink trick on /extension/ezfind/settings/solr.ini: I tend to name the versioned files like solr.ini_<port-number> where <port-number> is the actual port number that solr is going to be listening on. Note that the default port is 8983; so my two solr.ini files are:

solr.ini_8983
solr.ini_8984

The particular setting in solr.ini is, eg:

[SolrBase]
# Base URI of the Solr server
SearchServerURI=http://localhost:8984/solr 

The second file controls the Solr side of the connection: /extension/ezfind/java/etc/jetty.xml. I have two versions of this file which I manage also via a symlink:

jetty.xml_8983
jetty.xml_8984

And the setting is, eg:

<Set name="port"><SystemProperty name="jetty.port" default="8984"/></Set>

Now, so long as you have symlinked the correct versions of the two files, you're good to go: You can operate two (or more) instances of eZ Find on the same server.

The last part of this, which is optional, but is super convenient and pretty simple to accomplish is setting up the init.d script. This allows you to gracefully start, stop and check on the status of the solr server. Start with one of the default init.d scripts in .../extension/ezfind/bin/scripts/...

Create a copy of it, eg:
cp solr solrstage

Modify the copy so that it reads:

DESC="Solr stage indexing server"
NAME=solrstage

change all "solr.pid" to "solrstage.pid"

Install the mod'd script as root:

cp solrstage /etc/init.d/solrstage
cd /etc/init.d && chmod 755 solrstage   
cd /etc/rc3.d   
ln -s ../init.d/solrstage S71solrstage   
ln -s ../init.d/solrstage K71solrstage   
cd /etc/rc5.d   
ln -s ../init.d/solrstage S71solrstage   
ln -s ../init.d/solrstage K71solrstage

And now you can do:

sudo /etc/init.d/solrstage [start|stop|status]

to manage your solr servers. Once these are running nicely, this is much nicer than nohup'ing them or what-have-you.

Note that in the stock init.d scripts are good explanations for installation.