I have installed sphinx and have done all necessary changes followed this steps
wget http://www.sphinxsearch.com/downloads/sphinx-0.9.9.tar.gz
tar -xzf sphinx-0.9.9.tar.gz
After that, we should compile Sphinx from the source:
cd sphinx-0.9.9-rc2/
./configure
sudo make
sudo make install
In Rails 3, open Gemfile in the root directory and add the line below:
gem 'thinking-sphinx', :git => 'http://github.com/freelancing-god/thinking-sph
And run the following command:
bundle install
Thinking Sphinx gem adds a few rake tasks to your application. The most important ones:
rake thinking_sphinx:index – Create the index
rake thinking_sphinx:reindex – Reindex Sphinx without regenerating the configuration file
rake thinking_sphinx:start – Start up Sphinx's daemon
rake thinking_sphinx:stop – Shut down the daemon
but getting error FATAL: no indexes found in config file '/home/gvo/dcms/config/development.sphinx.conf'
but when i run same with RAILS_ENV= production it works fine. Any suggestion or help would be really great.
Yeah, those names are confusing. You need to make sure the ThinkingSphinx configuration in app/config/sphinx.yml (paths, what to index) is available to the TS gem for your environment. TS uses this config to generate the configuration used by the underlying Sphinx server. You may have to create needed directories for the indexer to be able to write index files, logs, and a few other things. It's likely that the config for development is different than production.
Related
I´m having trouble to access the rails console in production.
I used Capistranoto deploy the app to a VPS
If I cd to deploy#myapp:~/myapp/current$and run bundle exec rails cthere I always get the option list for creating new rails project, like rails new
I've also tried bundle exec rails console --productionand rails consoleetc all with the same outcome.
the thing is I must be able to access the console because I have to create an admin user for active admin
might be worth adding that I'm using Passenger/Capistrano and Nginx on Ubuntu 16
Does anyone know what is going on here? Am I doing something wrong?
*EDIT
After running RAILS_ENV=production bundle exec rails c I get this message
Looks like your app's ./bin/rails is a stub that was generated by Bundler.
In Rails 4, your app's bin/ directory contains executables that are versioned
like any other source code, rather than stubs that are generated on demand.
Here's how to upgrade:
bundle config --delete bin # Turn off Bundler's stub generator
rake rails:update:bin # Use the new Rails 4 executables
git add bin # Add bin/ to source control
You may need to remove bin/ from your .gitignore as well.
When you install a gem whose executable you want to use in your app,
generate it and add it to source control:
bundle binstubs some-gem-name
git add bin/new-executable
Loading production environment (Rails 4.2.5)
irb(main):001:0>
You are missing executable files of bin folder in Production after Capistrano deployment.
You need to remove bin from set :linked_dirs from your Capistrano deploy.rb in order to avoid symlinking it.
You can again try cap production deploy, it would take all the executable files from bin to Production.
Now, you can access the rails console using:
RAILS_ENV=production bundle exec rails c
If you are using Capistrano 3, you can include the rails:console option which will allow you to do this from your local machine to gain access to the console on the remote host:
bundle exec cap production rails:console
https://rubygems.org/gems/capistrano-rails-console
The Rails project is deployed in /deploy/your_project_name/current on the server by default. So, you can access it via SSH or ... and run bundle exec rails c to access the Rails console. It works for me!
check if rvm and regarding gemset is suitable for the app
rvm gemset list
rvm list
and then do
bin/rails rails c -e production
I am new to ruby and I want to learn more about how it works. So I have been testing a server configuration in a virtual machine to make quick Rails deployments.
I have RVM, Ruby, Rails, Git, Gitolite, PostgreSQL, Thin and Nginx running in an Ubuntu 10.04 environment.
Now I want to tie everything together. I got stuck, though, in the deployment process.
After I commit the project to the Git trunk, I want to hook a deployment action to put the application in the correct place, set to production, install the bundles, make the migrations and restart Nginx.
But I fail to find simple references on how it works. All I find in google are guides to use passenger, capistrano and others. I want to trigger the deployment on the git commit action, similar to heroku, but what would be the best tools to do that 100% server-side?
What about making some shell scripts? How do I deploy a project manually? What are the steps? Are there any guides out there that do not assume I know every details in Rails deployment?
Thanks!
The think you are probably looking for is a git post-receive hook (a tutorial could be found here: http://toroid.org/ams/git-website-howto).
By this hook you should trigger eg. a shell script which should perform all the steps you need - which are:
checkout HEAD commit from the git repo (git checkout -f, see linked tutorial)
run bundle install
run bundle exec rake db:migrate - this assumed that you have already created your DB
restart/start the Thin server cluster (no sure exactly here, if it is similar to passenger which I use this operation is just to create some restart.txt file) - I presume that you have your nginx as a reverse proxy in front of it, right?
This is the long-story short. It is little bit more complicated, eg. if you use the asset pipeline (rails >= 3.1), you would like to precompile you assets, etc. But the above is a good starting point.
Well, I managed to get it almost completely operational.
The main actions I could trace until now are:
User pushes to trunk, must use git hooks to trigger the next steps using a script.
The script must do the following:
Clone the project to the /var/www folder;
Insert the 'thin' gem into the Gemfile;
Run 'bundle' command in the application folder;
Precompile the assets in the application folder;
Migrate the database;
Stop nginx and thin;
Restart thin and nginx again.
If the application is new, we must also:
Create a new user that matches the database information;
Create the production database;
Insert a new nginx configuration file;
Export the thin configuration from the application folder, like this:
thin config -C /etc/thin/app.yml -c /var/www/app --servers 1 -e production
The sequence of actions is more or less this:
$ bundle package
$ bundle install --deployment
$ RAILS_ENV=production rake db:migrate
$ rake assets:precompile
$ thin start -C /etc/thin/app.yml
This is the basic by now. I want to make it work 100% and then I want to post a guide on the Internet.
Update
The guide I said I would do:
https://github.com/sentient06/RDH/wiki
I am unable to run rake tasks with cron. The error it throws up is:-
/Library/Ruby/Gems/1.8/gems/bundler-1.2.0/lib/bundler/runtime.rb:199: warning: Insecure world writable dir /Library/Ruby/Gems/1.8 in PATH, mode 040777
/Library/Ruby/Gems/1.8/gems/bundler-1.2.0/lib/bundler/spec_set.rb:90:in `materialize': Could not find unf_ext-0.0.5 in any of the sources (Bundler::GemNotFound)
However, when I run the same rake task directly from the terminal, it works fine. In case of the cron job, as well as while running the rake task directly from the terminal, i cd into the (exact) same directory. Starting the rails server works as well.
What is the problem and how should I resolve this?
It could be an issue with your daemon user and your user when you're running it directly. Or it could be a problem with Ruby and/or your cron file commands.
Firstly, use this gem for making cron jobs with rake tasks:
https://github.com/javan/whenever
Then install RVM since you're using the standard ruby library provided by OSX and that can lead to some problems when you're developing various projects. This should fix the permissions error that you have displayed.
Having some issues deploying this. I've tried to deploy it twice now. Here's what I've done so far....
Installed the gems and versions required on the install page:
gem install -v=2.3.5 rails
gem install -v=1.0.1 rack
gem install -v=0.8.7 rake
gem install -v=0.4.2 i18n
Downloaded the package:
git clone git://github.com/chiliproject/chiliproject.git
cd chiliproject
git checkout stable
Had to find and set bundle since it wasn't in my path:
BUNDLE="/usr/lib/ruby/gems/1.8/bin/bundle"
Put my database info into database.yml:
And then started the bundle stuff:
$BUNDLE install --without=postgres rmagick
$BUNDLE exec rake generate_session_store
The last command got the error:
rake aborted!
can't activate rails (= 2.3.5, runtime), already activated rails-2.3.12. Make sure all dependencies are added to Gemfile.
So I changed 2.3.12 to 2.3.5 in the Gemfile and carried on:
RAIL_ENV=production $BUNDLE exec rake db:migrate
Then I got an error on this command too:
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
undefined method `autoload_paths' for #<Rails::Configuration:0x68a68dbb82c0>
/home/USERNAME/DOMAIN/public/config/environment.rb:44
I tried commenting out line 44 there, but then it threw another error undefined methodconvert_to_without_fallback_on_iso_8859_1' for class Class' so I didn't want to play around with it further. Note this only happened the second time I tried to deploy it. The first time I tried db:migrate succeeded (and I checked there was not data already in the DB).
*So for the second try I am stuck here :-( *
But this is what happened the first time after db:migrate succeded....
RAILS_ENV=production $BUNDLE exec rake redmine:load_default_data
With the last command however it failed saying permission denied for mysql 'user'#'173.236.128.0/255.255.128.0' and I was like WTF is it trying to connect to a network as if it were a host?
So I moved on, copied my configuration file and environment files in. Changed/added these lines:
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.5'# unless defined? RAILS_GEM_VERSION
if ENV['RAILS_ENV'] == 'production' # don't bother on dev
ENV['GEM_PATH'] = '/home/USERNAME/.gems' + ':/usr/lib/ruby/gems/1.8'
end
Then made this stuff writable and restarted Passenger:
chmod -R 777 files log tmp public/plugin_assets/
touch tmp/restart.txt
Sorry for the wall of text, is anybody able to shine some light on something I've done wrong?
Thanks in advance.
EDIT: So this is all wrong, here's how I got it working
rm ~/.gem*
gem install bundler
PATH=$PATH:/usr/lib/ruby/gems/1.8/bin
cd ~
git clone git://github.com/chiliproject/chiliproject.git
cd chiliproject
git checkout stable
cp * ../example.com/ -R
cd ../example.com
# Make sure database is working
bundle install --without postgres rmagick test
bundle exec rake generate_session_store
RAILS_ENV=production bundle exec rake db:migrate
# No output is no good, check database.yml
RAILS_ENV=production bundle exec rake redmine:load_default_data
Or see this: https://gist.github.com/1127306
The current ChiliProject stable releases (2.x) require the use of bundler. Thus the answer by Slotos is incorrect here. gen install doesn't work anymore, we NEED bundler.
Also, we require Rails 2.3.12 now. You won't get any working results if you arbitrarily edit files. On certain platforms, you need to adapt the Gemfile (e.g. when using Ruby 1.8.6 or for certain versions of ImageMagick). For the currently suggested setup using Ruby 1.8.7 or REE, you don't need to adapt anything though.
For installing the dependencies of the currently stable ChiliProject 2.x releases, you basically need to do the following:
At first you need to make sure that the directory where gem binaries re installed to is in your $PATH. This can be temporarily be achieved by running this (in your case)
export PATH=/usr/lib/ruby/gems/1.8/bin:$PATH
Then you need to install the bundler gem and instruct it to install all dependencies
gem install bundler
bundle install --without rmagick postgres test # in your case
What is really strange in your case is that rake seems to try to enable Rails 2.3.5. It should not do that (and doesn't unless you have changed certain files). I strongly recommend to start with a new clean source tree and don't change any arbitrary files.
Don't mix up gem install commands with bundler package management. You will get unexpected results from doing so.
If you really want to use bundler - add all the gems you want into a Gemfile.
Otherwise just omit it.
Quick search for "bundler chiliproject" lead me to chiliproject-gemfile. Apparently it have been merged into unstable already.
In Rails 2 you're able to run
script/console --sandbox
so you can play with production data and not accidentally break anything.
I can't seem to find the equivalent command for Rails 3. Does anyone know what it is?
Easy, type in:
bundle exec rails c -s
and that is it.
$ bundle exec rails c --help
Usage: console [environment] [options]
-s, --sandbox Rollback database modifications on exit.
--debugger Enable ruby-debugging for the console.
--irb DEPRECATED: Invoke `/your/choice/of/ruby script/rails console` instead
It is simple, but, sometimes, if you are not running rails executable using bundle exec, it may, or may not, result in an error. In order to avoid this, ALWAYS use bundle exec.
To quote bundler page (if not documentation):
In some cases, running executables without bundle exec may work, if
the executable happens to be installed in your system and does not
pull in any gems that conflict with your bundle.
However, this is unreliable and is the source of considerable pain.
Even if it looks like it works, it may not work in the future or on
another machine.