We ported our Rails 5.2 app to Heroku and were able to get almost everything working with FlyingSphinx.
Search and indexing work well but as a convenience to our users, we try to let them know when the daemon is down for service or if we're re-indexing.
Previously, we were able to use
ThinkingSphinx::Configuration.instance.controller.running?
But this always returns false
on Heroku even if the daemon is running.
Our thinking_sphinx.yml
doesn't specify file locations or information on where the pid is, so I suspect this may be the issue; however, I can't find anywhere that would explain what to use in thinking_sphinx.yml
for Heroku/FlyingSphinx, if it's at all necessary https://freelancing-gods.com/thinking-sphinx/v3/advanced_config.html.
Our thinking_sphinx.yml
looks like this now:
common: &common
mem_limit: 40M
64bit_timestamps: true
development:
<<: *common
test:
<<: *common
mysql41: 9307
quiet_deltas: true
staging:
<<: *common
quiet_deltas: true
production:
<<: *common
version: '2.2.11'
quiet_deltas: true
Suggestions?
Ah, I've not had this requested before, but it's definitely possible:
require "flying_sphinx/commands" if ENV["FLYING_SPHINX_IDENTIFIER"]
ThinkingSphinx::Commander.call(
:running,
ThinkingSphinx::Configuration.instance,
{}
)
When this is called locally, it'll check the daemon via the pid file, but when it's called on a Heroku app using Flying Sphinx, it talks to the Flying Sphinx API to get the running state. Hence, it's important to only run the require
call for Heroku-hosted environments - there's no point having local/test envs calling the Flying Sphinx API.
Setting file/pid locations in Heroku/Flying Sphinx environments are mostly not going to do anything, because Flying Sphinx overwrites these anyway to match the standardised approach on their servers. The exceptions are for stopfiles/exceptions/etc, and those corresponding files are uploaded to Flying Sphinx so the daemon there can be configured appropriately.