Thinking Sphinx - Errors out when i try to reindex? - ruby-on-rails

Ok so i have a rails application on our server and I have thinking shinx installed. Every day at 12:30am I run a cron job that truncates the account and contact tables and reinserts them...here is my crons
30 0 * * * /bin/bash -l -c 'cd /var/www/active && script/rails runner -e production '\''Account.db_insert'\$
34 0 * * * /bin/bash -l -c 'cd /var/www/active && RAILS_ENV=production bundle exec rake ts:index --silent'
34 0 * * * /bin/bash -l -c 'cd /var/www/active && RAILS_ENV=production bundle exec rake ts:restart --silent'
As you can see the crons executes the Account.db_insert which reinserts contacts and accounts but everyday I get an email with an error....here are the two that i got recently....
Yesterdays Error
using config file '/var/www/active/config/production.sphinx.conf'...
indexing index 'contact_core'...
FATAL: failed to lock /var/www/active/db/sphinx/production/contact_core.spl: Resource temporarily unavailable, will not index. Try --rotate option.
Todays Error
using config file '/var/www/active/config/production.sphinx.conf'...
indexing index 'contact_core'...
collected 403 docs, 0.0 MB
sorted 0.1 Mhits, 100.0% done
ERROR: index 'contact_core': rename /var/www/active/db/sphinx/production/contact_core.tmp.spl to /var/www/active/db/sphinx/production/contact_core.new.spl failed: No such file or directory.
total 403 docs, 25092 bytes
total 0.069 sec, 361571 bytes/sec, 5807.16 docs/sec
distributed index 'contact' can not be directly indexed; skipping.
total 5 reads, 0.001 sec, 133.7 kb/call avg, 0.2 msec/call avg
total 10 writes, 0.012 sec, 177.8 kb/call avg, 1.2 msec/call avg
Any Idea what I am doing wrong....
UPDATE
After the suggestion to run
/usr/local/bin/indexer --config /etc/sphinxsearch/sphinx.conf --all --rotate
I got this error
using config file '/etc/sphinxsearch/sphinx.conf'...
ERROR: unknown key name 'client_timeout' in /etc/sphinxsearch/sphinx.conf line 591 col 16.
FATAL: failed to parse config file '/etc/sphinxsearch/sphinx.conf'.

As the error message indicates, you might want to run the indexer with the --rotate switch.
I, too, use Thinking Sphinx but found it easier to just use the Sphinx indexer directly. I have Thinking Sphinx generate my config for me, then I can just call out to searchd and indexer directly, in my cron:
*/30 * * * * /usr/local/bin/indexer --config /etc/sphinxsearch/sphinx.conf --all --rotate
I have foundthis to be more helpful than going through the Rake tasks. In addition, its much faster as the whole Rails stack doesnt have to be loaded.

Related

Can't get Ruby Whenever working

I'm having some trouble getting whenever to work in my local dev environment. I'm using mac OS 10.12, ruby 2.4, rails 5.1 and whenever 0.10.0.
I have my schedule.rb file setup as:
set :environment, "development"
set :job_template, "TZ=\"America/Los_Angeles\" bash -l -c ':job'"
set :output, Whenever.path + "/log/cron.log"
every 5.minutes do
runner "Test.new.run"
command "/bin/echo 'Is this working?'"
end
crontab -l outputs the following:
# Begin Whenever generated tasks for: /Users/me/apps/Test/config/schedule.rb at: 2018-05-25 12:59:14 -0700
0,5,10,15,20,25,30,35,40,45,50,55 * * * * TZ="America/Los_Angeles" bash -l -c 'cd /Users/me/apps/Test && bundle exec bin/rails runner -e development '\''Test.new.run'\'' >> /Users/me/apps/Test/log/cron.log 2>&1'
0,5,10,15,20,25,30,35,40,45,50,55 * * * * TZ="America/Los_Angeles" bash -l -c '/bin/echo '\''Is this working?'\'' >> /Users/me/apps/Test/log/cron.log 2>&1'
# End Whenever generated tasks for: /Users/me/apps/Test/config/schedule.rb at: 2018-05-25 12:59:14 -0700
and I'm receiving the following when I run the mail command in terminal:
Message 1:
From me#box.local Fri May 25 13:00:01 2018
X-Original-To: me
Delivered-To: me#box.local
From: me#box.local (Cron Daemon)
To: me#box.local
Subject: Cron <me#box> TZ="America/Los_Angeles" bash -l -c '/bin/echo '\''Is this working?'\'' >> /Users/me/apps/Test/log/cron.log 2>&1'
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=me>
X-Cron-Env: <USER=me>
X-Cron-Env: <HOME=/Users/me>
Date: Fri, 25 May 2018 13:00:00 -0700 (PDT)
However, I'm not seeing anything output to cron.log nor does the DB reflect any activity from Test.new.run
Not really sure what I'm doing wrong...
I think the problem may have had to do with rvm and the .rvmrc file I had set up which loaded the correct rvm settings when I cd into the directory.
In attempting to ensure that the command was working opened a new terminal window and ran: bash -l -c 'cd /Users/me/apps/Test && bundle exec bin/rails runner -e development '\''Test.new.run'\'' >> /Users/me/apps/Test/log/cron.log 2>&1'
The first thing that came up was the standard 1 off rvm message:
You are using '.rvmrc', it requires trusting, it is slower and it is not compatible with other ruby managers,
you can switch to '.ruby-version' using 'rvm rvmrc to ruby-version'
or ignore this warning with 'rvm rvmrc warning ignore /Users/me/apps/Test/.rvmrc',
'.rvmrc' will continue to be the default project file in RVM 1 and RVM 2,
to ignore the warning for all files run 'rvm rvmrc warning ignore all.rvmrcs'.
********************************************************************************
* NOTICE *
********************************************************************************
* RVM has encountered a new or modified .rvmrc file in the current directory, *
* this is a shell script and therefore may contain any shell commands. *
* *
* Examine the contents of this file carefully to be sure the contents are *
* safe before trusting it! *
* Do you wish to trust *
* '/Users/me/apps/Test/.rvmrc'? *
* Choose v[iew] below to view the contents *
********************************************************************************
y[es], n[o], v[iew], c[ancel]>
Once I typed y and hit enter, the cron jobs are now executing properly.
Unfortunately, I'm still not seeing anything in my cron.log file.

Cronjob is running every hour but not at a specific time

I have a cronjob on my server that suppose to run a rake script on my rails app everyday at specific time (eg. 8.00 am). I use whenever gem to automate this. This is how it appears currently on the cron file:
0 8 * * * /bin/bash -l -c 'cd /home/deploy/apps/myapp/releases/20160121092339 && RAILS_ENV=production bundle exec rake overdue_payments --silent >> /home/deploy/apps/myapp/releases/20160121092339/log/cron.log 2>&1'
And it's not working. But strangely enough, if I edit my cron to run for every hour, it is working just fine! Here is how I did it to make it run for every hour:
0 * * * * /bin/bash -l -c 'cd /home/deploy/apps/myapp/releases/20160121092339 && RAILS_ENV=production bundle exec rake overdue_payments --silent >> /home/deploy/apps/myapp/releases/20160121092339/log/cron.log 2>&1'
I have modified my timezone to the local timezone (UK) but still not working:
We need to specify the timezone to cronjob description. Here is my example:
test_cron_job:
cron: "45 11 * * * Asia/Bangkok"
class: "Schedulers::TestCronJob"
queue: default
Above cronjob will be run at 11:45 am in Bangkok time. Btw you may find out your timezone by using:
ActiveSupport::TimeZone.zones_map.values.map(&:tzinfo).map(&:identifier)
I finally solved it! For the timezone, i just need to add TZ before it. So for my case it will be: TZ="Europe/London".
0 8 * * * TZ="Europe/London" /bin/bash -l -c 'cd /home/deploy/apps/myapp/releases/20160121092339 && RAILS_ENV=production bundle exec rake overdue_payments --silent >> /home/deploy/apps/myapp/releases/20160121092339/log/cron.log 2>&1'
Hope this solution help you
every :day, :at => (6..8).to_a.map { |x| ["#{x}:00","#{x}:30", "#{x+1}:00"] }.flatten do
# Run rake task.
end
# => ["6:00", "6:30", "7:00", "7:00", "7:30", "8:00", "8:00", "8:30", "9:00"]
Adjust initial range and the inner block to cover any range. Its support 24hr clock.

Crontab in Amazon Elastic Beanstalk

I am doing a cron tab in AWS - Elastic Beanstalk with Ruby on Rails 3, but I don't know what is wrong.
I have this code in my .ebextensions/default.config
container_commands:
01remove_old_cron_jobs:
command: "crontab -r || exit 0"
02send_test_email:
command: crontab */2 * * * * rake send_email:test
leader_only: true
I receive this error:
Failed on instance with return code: 1 Output: Error occurred during build: Command 02send_test_email failed .
UPDATE 1
I tried next:
crontab.txt
*/2 * * * * rake send_email:test > /dev/null 2>&1
default.config
02_crontab:
command: "cat .ebextensions/crontab.txt | crontab"
leader_only: true
RESULT: No errors, but it does not work.
UPDATE 2
crontab.sh
crontab -l > /tmp/cronjob
#CRONJOB RULES
echo "*/2 * * * * /usr/bin/wget http://localhost/crontabs/send_test_email > /dev/null 2>&1" >> /tmp/cronjob
#echo "*/2 * * * * rake send_email:test > /dev/null 2>&1" >> /tmp/cronjob
crontab /tmp/cronjob
rm /tmp/cronjob
echo 'Script successful executed, crontab updated.'
default.config
02_crontab:
command: "/bin/bash .ebextensions/crontab.sh"
leader_only: true
RESULT: Works with url, but not with rake task.
Updated for 2018
In order to get this to work on the latest version of Elastic Beanstalk, I added the following to my .ebextensions:
.ebextensions/0005_cron.config
files:
"/etc/cron.d/mycron":
mode: "000644"
owner: root
group: root
content: |
56 11 * * * root . /opt/elasticbeanstalk/support/envvars && cd /var/app/current && /opt/rubies/ruby-2.3.4/bin/bundle exec /opt/rubies/ruby-2.3.4/bin/rake send_email:test >> /var/app/current/log/cron.log 2>&1
commands:
remove_old_cron:
command: "rm -f /etc/cron.d/*.bak"
How I got there:
There are four main issues to confront when trying to cron a rake task in AWS EB:
The first hurdle is making sure all of your EB and Rails environment variables are loaded. I beat my head against the wall a while on this one, but then I discovered this AWS forum post (login may be required). Running . /opt/elasticbeanstalk/support/envvars loads all of your environment variables.
Then we need to make sure we cd into the current app directory using cd /var/app/current.
Next we need to know where to find the bundle and rake executables. They are not installed in the normal bin directories, but are located in a directory specific to your ruby version. To find out where your executables are located, ssh into your EB server (eb ssh) and then type the following:
$ cd /var/app/current
$ which bundle
/opt/rubies/ruby-2.3.4/bin/bundle
$ which rake
/opt/rubies/ruby-2.3.4/bin/rake
You could probably guess the directory based on your ruby version, but the above commands will let you know for sure. Based on the above, your can build your rake command as:
/opt/rubies/ruby-2.3.4/bin/bundle exec /opt/rubies/ruby-2.3.4/bin/rake send_email:test
NOTE: If you update your ruby version, you will likely need to update your cron config as well. This is a little brittle. I'd recommend making a note in your README on this. Trust me, six months from now, you will forget.
The fourth thing to consider is logging. I'd recommend logging to the same location as your other rails logs. We do this by tacking on >> /var/app/current/log/cron.log 2>&1 to the end of our command string.
Putting all of this together leads to a cron command string of:
. /opt/elasticbeanstalk/support/envvars && cd /var/app/current && /opt/rubies/ruby-2.3.4/bin/bundle exec /opt/rubies/ruby-2.3.4/bin/rake send_email:test >> /var/app/current/log/cron.log 2>&1
Finally, I referenced the latest AWS documentation to build an .ebextensions config file for my cron command. The result was the .ebextensions/0005_cron.config file displayed at the top of this answer.
I am having the same issue. Though I figured out that the reason that rake task doesn't run correctly on eb is because of RACK_ENV, RAILS_ENV and BUNDLE_WITHOUT
Defaults of eb:
RACK_ENV: production
RAILS_ENV: production
BUNDLE_WITHOUT: test:development
When the cron runs rake task, it runs in development mode, and gives gem not found error, as gems grouped in development are not installed.
you can see this by changing your cron a bitfrom:
*/2 * * * * rake send_email:test > /dev/null 2>&1
to:
*/2 * * * * cd /var/app/current/ && /usr/bin/bundle exec /usr/bin/rake send_email:test > /tmp/cron_log 2>&1
and then checking the /tmp/cron_log file
To know the location of bundle and rake, run
which bundle
which rake
I tried setting RAILS_ENV in command in cron, but that didn't work aswell
One quick fix is to set
BUNDLE_WITHOUT to null
EDIT:
Finally I got it to work,
.ebextensions/.config
files:
"/tmp/cron_jobs" :
mode: "000777"
content: |
1 10 * * * cd /var/app/current/ && RACK_ENV=production rake some:task >> /var/app/current/log/cron_log 2>&1
encoding: plain
container_commands:
01_delete_cron_jobs:
command: "crontab -r -u webapp || exit 0"
02_add_cron_jobs:
command: "crontab /tmp/cron_jobs -u webapp"
leader_only: true
option_settings:
- option_name: RAILS_ENV
value: production
- option_name: RACK_ENV
value: production
Notice the '-u webapp' when removing and adding cron, this will run this cron under user webapp. The above will also run in production mode. And the output will be dumped in log/cron_log file.
If the above wont work then adding 'Bundle exec' before 'rake some:task' might work.
I've seen these used with separate files in .ebextensions, such as:
02send_test_email:
command: "cat .ebextensions/crontab | crontab"
leader_only: true
I haven't gotten around to it yet, but I took note of this along the way. Let us know if this works.
This stackoverflow post has much more information
After Update 1/2:
Cron doesn't know where rake is. Your application runs from /var/app/current, and you need to be running bundle exec rake from that directory.
Elastic beanstalk is horrible with logging errors, to get this right, ssh to the machine and experiment until you have the commands right, then put this back into your cron script. You can even try and re-run some of the eb scripts as found in the logs, then reverse that into your ebextensions files.

Whenever rails gem not working with cronjob.. why?

I am using Whenever gem with rails. For some reason the first cronjob does not work. If i copy paste the command into the shell manually, it works as it should.
The second "touch testing123.txt" also works fine.
I have no idea why the GiftPackage.do_scheduled_deliveries rails method does not run. I'm really at a loss right now.. any help would be greatly appreciated!
# Begin Whenever generated tasks for: /var/www/mysite/releases/20130131200554/config/schedule.rb
*/1 * * * * /bin/bash -l -c 'cd /var/www/mysite/releases/20130131200554 && script/rails runner -e staging '\''GiftPackage.do_scheduled_deliveries'\'''
*/1 * * * * /bin/bash -l -c 'cd /var/www/mysite/releases/20130131200554 && touch testing123.txt'
# End Whenever generated tasks for: /var/www/mysite/releases/20130131200554/config/schedule.rb
Thanks!
:)
Most likely you are getting an error within the app itself.
First step would be, run the task in the console using the staging environment.
Second would be to check the cron logs and see if it is outputting any errors.
You can set whenever to log output by adding the following to your schedule.rb file;
set :output, "/[path to log]/cron.log"
This should help you get closer to finding the solution.
Try setting your PATH variable before the jobs, your cron is probably not able to find ruby :
For instance :
PATH=/usr/local/rvm/gems/ruby-1.9.3-p194/bin:/usr/local/rvm/gems/ruby-1.9.3-p194#global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p194/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/$
# Begin Whenever generated tasks for: /var/www/mysite/releases/20130131200554/config/schedule.rb
*/1 * * * * /bin/bash -l -c 'cd /var/www/mysite/releases/20130131200554 && script/rails runner -e staging '\''GiftPackage.do_scheduled_deliveries'\'''
*/1 * * * * /bin/bash -l -c 'cd /var/www/mysite/releases/20130131200554 && touch testing123.txt'
# End Whenever generated tasks for: /var/www/mysite/releases/20130131200554/config/schedule.rb

Setting up thinking sphinx after server reboot (Rails project)

Problem:
I am trying to get sphinx running again after server reboot. There seems to be no sphinx.conf file when I try to start it running:
>searchd
Sphinx 2.0.4-release (r3135)
Copyright (c) 2001-2012, Andrew Aksyonoff
Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)
FATAL: no readable config file (looked in /etc/sphinxsearch/sphinx.conf, ./sphinx.conf).
I have run:
rake thinking_sphinx:configure
rake thinking_sphinx:index
rake thinking_sphinx:start
The problem is for some reason no etc/sphinxsearch/sphinx.conf file is being created... I am new to thinking_sphinx and this might not be the only problem (with the site), but it doesn't seem to be set up fully. For out put and more information read below:
Background info:
I am working on a project I didn't set up initially. We rebooted the server to see some of the changes we made in a constants file. But after the reboot the project no longer displays when you navigate to the site. When you put in the straight ip address it just says "Welcome to Nginx".
The port is open and working through our hosting server, so I was told I have to restart some services. One of the issues I came upon was with thinking_sphinx. This was the rake tasks for sphinx site I referenced. As well as common configuration issues for sphinx.
I set up the sphinx.yml development paths (we aren't using production). Then I ran
>rake thinking_sphinx:index
which seems to have worked even though it output some warnings:
Generating Configuration to /home/potato/streetpotato/config/development.sphinx.conf
(0.2ms) SELECT ##global.sql_mode, ##session.sql_mode;
Sphinx 2.0.4-release (r3135)
Copyright (c) 2001-2012, Andrew Aksyonoff
Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)
using config file '/home/potato/streetpotato/config/development.sphinx.conf'...
indexing index 'bar_core'...
WARNING: collect_hits: mem_limit=0 kb too low, increasing to 14080 kb
collected 249 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 249 docs, 32394 bytes
total 0.254 sec, 127298 bytes/sec, 978.49 docs/sec
indexing index 'bar_delta'...
WARNING: collect_hits: mem_limit=0 kb too low, increasing to 14080 kb
collected 0 docs, 0.0 MB
total 0 docs, 0 bytes
total 0.003 sec, 0 bytes/sec, 0.00 docs/sec
skipping non-plain index 'bar'...
indexing index 'synonym_core'...
WARNING: collect_hits: mem_limit=0 kb too low, increasing to 13568 kb
collected 3 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 3 docs, 103 bytes
total 0.003 sec, 30356 bytes/sec, 884.17 docs/sec
indexing index 'synonym_delta'...
WARNING: collect_hits: mem_limit=0 kb too low, increasing to 13568 kb
collected 0 docs, 0.0 MB
total 0 docs, 0 bytes
total 0.002 sec, 0 bytes/sec, 0.00 docs/sec
skipping non-plain index 'synonym'...
indexing index 'user_core'...
WARNING: collect_hits: mem_limit=0 kb too low, increasing to 13568 kb
collected 100 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 100 docs, 3146 bytes
total 0.013 sec, 239348 bytes/sec, 7608.03 docs/sec
skipping non-plain index 'user'...
total 11 reads, 0.000 sec, 3.8 kb/call avg, 0.0 msec/call avg
total 37 writes, 0.000 sec, 2.5 kb/call avg, 0.0 msec/call avg
Then I ran
>rake thinking_sphinx:configure
Generating Configuration to /home/potato/streetpotato/config/development.sphinx.conf
(0.2ms) SELECT ##global.sql_mode, ##session.sql_mode;
Lastly running:
>rake thinking_sphinx:start
Started successfully (pid 29623).
Now even though my log says:
[Fri Nov 16 19:34:29.820 2012] [29623] accepting connections
There is still no sphinx.conf file being generated and when I try to use the searchd command it still gives me the error...
>searchd --stop
Sphinx 2.0.4-release (r3135)
Copyright (c) 2001-2012, Andrew Aksyonoff
Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)
FATAL: no readable config file (looked in /etc/sphinxsearch/sphinx.conf, ./sphinx.conf).
I am at a loss, I know this is super long but only because I am so lost and trying to give as much information as possible. I got further then I did yesterday with this but it still doesn't seem to be fully working. I might have to do more set up with unicorn or thin as well. I'm just trying to figure out how to get the site back up and running again... If any one has run into similar issues with their site going down after reboot and got it back up (specifically a rails project on Nginx and unicorn or thin using sphinx) any insight would be appreciated.
Thanks,
Alan
Calm down!! :-)
Firstly, you don't need a /etc/sphinxsearch/sphinx.conf file; that is just the default file that searchd tries to use when you don't specify any configuration file.
As your log output shows, your rails application is using /home/potato/streetpotato/config/development.sphinx.conf file when it starts the searchd process.
Run ps -fe | grep searchd on your dev machine; you should see something like this as the output:
501 14128 1 0 0:00.00 ttys004 0:00.00 searchd --pidfile --config /home/potato/streetpotato/config/development.sphinx.conf
501 14130 13546 0 0:00.00 ttys004 0:00.01 grep searchd
So rails app calls searchd with --config /home/potato/streetpotato/config/development.sphinx.conf argument, to specify a different conf file.
From your logs, it is clear that thinkingsphinx is running fine. You can confirm it further by logging into rails console and running a search method on one of the models which have thinking_sphinx indexes defined on them.
Eg: If your app has an Article model as shown in the above link, the following command will show all articles having National Parks in them:
$ rails console
> Article.search( "National Parks" )
=> [#<Article id: 15,... >, #<Article id: 22,...>,...]
The real problem is the application not showing after restarting the server. That has nothing to do with thinking sphinx which is running fine.
Try rolling back all the changes made in the constants file that you mention above, and make sure the application is working fine. Then start making the changes one by one and isolate the one change that breaks your application.
So yeah, this is a hole in ThinkingSphinx (IMHO) -- you can start the sphinxd server using the various rake tasks (which generate the config as needed) ... but this doesn't work in production.
On a project I worked in last year (running on a Linux server) we created an /etc/init.d script to start sphinxd -- it takes options including a path to the configuration file. We did our deploys with capistrano, and put generated code in app/shared -- a directory outside of the source tree. I believe there are some predefined capistrano tasks that will rebuild the Rails-specific config files when models change or otherwise affect what Sphinx does (same as the rake task you mention).
This was one of those cases for us where we had been putting off site search for a long time, and one of our developers got it "all set up" in an afternoon. Getting it deployed took a lot more work.
(Just saw answer from #prakash-murthy -- he provides some details of how to specify config path when you initialized sphinxd). But the trick is to have it start when the system starts and pointing to the config that ThinkingSphinx generates.)
Ok so after a day n a half I finally set it all up and got it running (it was more then just sphinx). I also had to get nginx and unicorn up and running in the background, since we didn't have scripts set up to restart them when the server was rebooted...
When rebooting the server you have to restart some services before the app will be accessible:
1) thinking_sphinx
reference sites
http://pat.github.com/ts/en/rake_tasks.html
http://www.claytonlz.com/2010/09/thinkingsphinx-conf-problems/
a)create/modify app/config/sphinx.yml
development:
morphology: stem_en
port: 9312
bin_path: "/usr/bin" # set up the path to binary for searchd
searchd_binary_name: searchd
indexer_binary_name: indexer
#mem_limit: 128M
test:
morphology: stem_en
port: 9312
mem_limit: 128M
production:
morphology: stem_en
port: 9312
mem_limit: 512M
# the searchd ip, in case it's not on localhost
# address: 10.10.0.0
# this is by default included in db/sphinx
# searchd_file_path: "/path/to/shared/folder/sphinx"
b)rake thinking_sphinx:index
c)rake thinking_sphinx:configure # creates config/development.sphinx.conf which helps define sphinx's indexing
d)# then you have to start sphinx, there are 2 ways to do this
rake thinking_sphinx:start
rake thinking_sphinx:stop
OR
searchd
searchd --stop
# only the rake commands worked for me, when I tried to run searchd
# I got an error FATAL: no readable config file (looked in /etc/sphinxsearch/sphinx.conf, ./sphinx.conf).
# for some reason we dont have a sphinx.conf file, but the rake commands work without it
e)# once you start thinking_sphinx check log/searchd.log file for the line
[Fri Nov 16 19:34:29.820 2012] [29623] accepting connections
2) nginx
reference site:
http://wiki.nginx.org/CommandLine
a) check that nginx is up and running
i) start server
# to check where nginx resides type in this into server console
which nginx
# whatever path it gives you is how you start the server this is my path
/usr/sbin/nginx
ii) stop server
/usr/sbin/nginx -s stop # use the path given by which command
3) unicorn (starting app server)
reference site:
http://codelevy.com/2010/02/09/getting-started-with-unicorn.html
a) test if unicorn will run after previous changes
unicorn_rails -p 3000
# the site should now be up and running, check that it is
# console should now log the different actions you do on the site
b) create unicorn.rb in config folder (if none is there)
# only start this step if the step above got the site running
# close the console or exit the process you started above
# contents of unicorn.rb
worker_processes 2 #(starts 2 child processes, not completely neccissary)
preload_app true
timeout 30
listen 3000
after_fork do |server, worker|
ActiveRecord::Base.establish_connection
end
c) run unicorn in the background
# make sure you exited the process above before running this
unicorn_rails -c config/unicorn.rb -D
# this was giving me an error that it said was logged by stderr
# I got the command to run by adding a command to the front
http://stackoverflow.com/questions/2325152/check-for-stdout-or-stderr
exec 2> /dev/null unicorn_rails -c config/unicorn.rb -D
d) (optional) check stats from starting unicorn
i) pgrep -lf unicorn_rails
#sample output
5374 unicorn_rails master -c config/unicorn.rb -D
5388 unicorn_rails worker[0] -c config/unicorn.rb -D # not needed currently
5391 unicorn_rails worker[1] -c config/unicorn.rb -D # not needed currently
ii) cat tmp/pids/unicorn.pid # from inside the streetpotato folder
#sample output
5374

Resources