I am using the following gems in my project
gem 'sunspot_rails'
group :development do
gem 'sunspot_solr'
end
I am trying to figure out why we shouldn't use sunspot gem by itself in production environment?
Most people recommend setting up a standalone solr service such as jetty+solr or tomcat+solr
There are several links that explain solr in production:
Setup sunspot solr with rails in production environment
http://outoftime.github.io/pivotal-sunspot-presentation.html
http://wiki.apache.org/solr/EmbeddedSolr
But they dont say why?
I tried putting all production data and creating indexes as i would need in production and faced no problem.
Is there anyone who has used the sunspot_solr in production and faced problems?
Related
I am newbie with Heroku and trying to upload a static website to Heroku. Here is what I did with this one.
First, I made a static website named Y , and when I ran localhost:3000, it ran very ok.
Then I followed suggestions from internet, I changed my gemfile
gem 'sqlite3'
to
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
and, change my routes.rb file like this
Rails.application.routes.draw do
get 'home/index'
root 'home#index'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end
But when I tried to run heroku open , it still give me this error
Sorry for my newbie's question, but I am stucking with this one and very confusing. Could you please give me some ideas? Thank you very much.
Check your config/database.yml
You are using pg gem in production but your database.yml file is configured for sqlite3.
It's better to configure your app to use pg on both production and development as well.
You should change your gem file to use gem pg in development
Run bundle install
And then reconfigure your database.yml to use the pg database.
Then run
Rails db:create
Rails db:migrate
And dont forget to add our enviroment variables to heroku so that it can use the database.
I am trying to deploy a Rails project on Heroku. My Rails application uses mysql2.
I have tried using the taps gem but its not working. I get the following error when I run the command taps server mysql://root#localhost/heroku_ex tempuser tempass:
Failed to connect to database: Sequel::AdapterNotFound -> LoadError: cannot load such file -- mysql
Is there any way to deploy my application on Heroku? I would prefer to only use free add-ons if possible.
There are a few moving parts here.
First of all, Heroku doesn't support MySQL by default. If you want to use MySQL instead of PostgreSQL you will have to provision an add-on that provides it. There are currently at least two add-ons that provide MySQL or MariaDB¹ support with a free tier².
Next, Heroku doesn't run database servers on localhost. How can you handle different database configurations between your development machine and your Heroku server?
One strategy that is endorsed by Heroku is to store configuration in the environment. Following this model lets you alter your application's configuration by modifying environment variables instead of editing files. Luckily, Rails appears to override config/database.yml with configuration from the DATABASE_URL variable by default, so this approach should be a good fit.
Very often database add-ons will automatically set an environment variable for you. For example, the JawsDB Maria add-on sets JAWSDB_MARIA_URL when it is provisioned. This isn't the variable that Rails looks for, so you'll either have to tell Rails to look for JAWSDB_MARIA_URL instead of DATABASE_URL or manually set DATABASE_URL to contain the same URL that JawsDB provides in JAWSDB_MARIA_URL.
¹MariaDB is a fork of MySQL that aims to be fully-compatible.
²Note that the free tier may be quite limited, e.g. by only providing 5MB of storage. You may have to upgrade to a paid database tier as you continue to develop your application.
I have solved this by adding the pg gem in production and mysql2 in development environment.
group :development, :test do
gem 'mysql2'
end
group :production do
gem 'listen', '~> 3.0.5'
gem 'pg'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
I have about 3 apps on a Windows Server 2012 and all of them are different versions of rails. So far, I can run locally the app with the latest version of rails, but not the other two, which were deployed from Heroku. I wanted to make changes locally before I push them to Heroku but no luck. Is there any reference to that or is this even possible? thanks a lot!
Your problem is that you are trying to use sqlite with Heroku. Heroku requires using 'postgres' as the database
change the gemfile to the following
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
And then change your database.yml file to this
adapter: postgresql
My Active Admin Layout Not Comes in Production Environment.
I added in Gemfile
gem 'activeadmin', github: 'gregbell/active_admin'
See My Active Admin Page
Help me Please.
Thanks In Advance
Im using Rails 4 and after running the server in RAILS_ENV=production i would get the same layout as you did, although it works in the development environment. after searching in the web for different answers that one that work for me was the next. Heroku does NOT compile files under assets pipelines in Rails 4 i find the answer here.
add rails_12factor to your gemfile
gem 'rails_12factor', group: :production
then
bundle install
and then restart your server
i did some modifications to config/application.rb file but it never worked for me (somthing to do with precompile assets) therefor i dont think it's necessary.
hope it helps
I am using the sunspot gem inside a mountable engine. I am creating an engine out of an existing Rails 3.2 app so I know that my setup works when in a standard rails app.
Basically, I can't get Sunspot in development (when using spec/dummy - I know that it's normally used to for testing but everything else works just fine) to load the sunspot.yml file and find the running version of Solr.
My gemspec has:
s.add_dependency 'sunspot_rails', '= 2.0.0.pre.120417'
s.add_development_dependency 'sunspot_solr', '~> 1.3.3'
s.add_development_dependency 'sunspot_test', '~> 0.4.0'
My mountable engine has a dummy rails app at spec/dummy for testing. My spec/dummy/config/sunspot.yml contains:
development:
solr:
port: 8080
path: /solr
hostname: localhost
When I run a rails console (from inside spec/dummy) with bundle exec rails console I get a normal rails console.
Running Sunspot.config produces:
> Sunspot.config
=> #<LightConfig::Configuration:0x007f864aeee8a0
#properties=
{:solr=>
#<LightConfig::Configuration:0x007f864aeed0b8
#properties=
{:url=>"http://127.0.0.1:8983/solr",
:read_timeout=>nil,
:open_timeout=>nil}>,
:master_solr=>
#<LightConfig::Configuration:0x007f864aefb398 #properties={:url=>nil}>,
:pagination=>
#<LightConfig::Configuration:0x007f864af06ae0
#properties={:default_per_page=>30}>,
:indexing=>
#<LightConfig::Configuration:0x007f864af0bf18
#properties={:default_batch_size=>50}>}>
Clearly Sunspot isn't picking up my sunspot.yml file because the port is running on 8983 instead of 8080 where it's actually running.
Starting the Solr server via bundle exec rake sunspot:solr:start (inside spec/dummy) or bundle exec rake app:sunspot:solr:start (from root of engine) starts the server correctly on port 8080 so I know that that is reading sunspot.yml
There are few other people with similar questions but I'm not using the sunspot_mongoid gem and feel like it's something to do with the fact it's running inside an engine.
If anyone could give me a hand it would be much appreciated!
I can't say what's wrong here, but I can tell you that I am doing the same thing -- making an engine out of rails app -- and that I have solr 2.0.0-pre-something and now 2.1.0 working in all environments locally and deployed. So, it can work.
I guess I would move forward by reading through the code involved in starting solr and how it goes about finding the config.
Not super helpful, overall -- but at least there's a reply now that suggests you're not doomed. :)
I eventually found the answer to this. Adding s.add_development_dependency 'sunspot_solr', '~> 1.3.3' adds sunspot_solr to the development profile only to the gem - not when you are running an application containing the gem in development mode. This makes sense for a 'normal' gem - I just wasn't thinking straight.
So in order to get the gem into your app containing the engine, you ether to have it as a normal add_dependency or include it in the app's Gemfile.
Sorry for wasting your time #ian
Dave