Aliases below for using the sunspot in the background Aliases below for searching and killing these cases work ENV variables are available for the sunspot ports But, Functions for starting sunspots, processing the command and killing the spots only work after I leave .bashrc outside functions.
$ user_id is set before this sunspot_ports () is called and prints correctly the first time you log in to rebash - this is an alias for the source ~ .bashrc
I have aliases for development and production - this is just representative code.
sunspot_ports ()
{
sunspot_test_port=$(($user_id +5300))
echo "Your sunspot test port: $sunspot_test_port"
alias sunspot_run_test="RAILS_ENV=test sunspot-solr run -p${sunspot_test_port} &"
alias sunspot_kill_test="fuser -n tcp ${sunspot_test_port} -k"
export sunspot_production_port sunspot_development_port sunspot_test_port
}
solr_test()
{
sunspot_run_test
sleep 10;
"$@";
sunspot_kill_test;
}
.bashrc , sunspot_ports() . , , .
, .bashrc, - jruby-, jvm forking ( sunspot-solr start sunspot-solr end )