I am new to Capistrano and this is my first attempt using it to deploy my rails application. I believe I have my config/deploy.rb setup properly, but before I do
cap production deploy:setup
I want to make sure that no harm will happen to my database. The database for this project is already set and has data in it. I could not figure out if doing
cap production deploy:setup
will destroy my production database and re-create it as an empty DB. Opinions?
cap deploy:setup
When you run this command, Capistrano will SSH to your server, enter
the directory that you specified in the deploy_to variable, and create
a special directory structure that’s required for Capistrano to work
properly. If something is wrong with the permissions or SSH access,
you will get error messages. Look closely at the output Capistrano
gives you while the command is running.
This command will do nothing with your database.
Related
I have a very small app that even uses sqlite3 in production because there are never going to be any issues with multiple writes, etc. I want to use capistrano to quickly and painlessly deploy updates to this app. But when I run cap production deploy it dumps the entire app into a release folder and symlinks it to current. I know I can include the production.sqlite3 file in the deploy.rb to keep the data but it still seems overkill to clone the entire repo every time I want to push an update.
I couldn't find anything in the capistrano documentation for updates.
Essentially all I need cap to do is
make sure my local git HEAD is the same as master
SSH into the prod server and do a git pull
Run rake db:migrate if necessary
Run rake assets:clean assets:precompile
Restart Phusion Passenger
How would I accomplish that?
Just write your own bash or ruby script that does this. I think you are missing the point of Capistrano. Cloning the whole repo allows you to do deploy rollbacks, leaving the previous version as is. It takes into account deploys that fail, and will not mess with your production site during the deploy process.
I'm learning Ruby on Rails, and having lots of difficulty setting up.
So I have created this new app, using 'rails new' command.
Modified a bit, and now on way to deploy it on heroku.
First try, it failed because heroku required the app to use postgresql rather than sqlite3, which was set as a default database.
So I downloaded and installed postgresql, and here is the where the trouble began.
After installing the postgres, I set up the path.
And then I was unable to run the app locally anymore.
In command, "rails server" command is not working anymore, showing all kinds of error not being able to load stuff.
It looks like this:
D:\ruby\appname>rails server
c:\RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/pg-0.17.1-x86-mingw32/lib/pg.rb:10:in 'require': cannot load such file --2.1/pg_ext <LoadError>
and another bunch of load error.
No need to mention deploying on heroku, it fails everytime.
After installing postgresql, I can't use any database related commands as it says "loaderror" everywhere.
I can't run the app locally, nor deploy on heroku.
How should I fix this database problem?
In development you can still use SQLite, and in production use Postgres.
It's not advisable forever to have that disparity, but it does mean you an make progress.
Remove any production settings in database.yml, but still include 'pg' in your Gemfile.
Heroku will automatically insert database settings for Postgres in production. Deploy and then run heroku run rake db:migrate to set up your database.
I needed to migrate my database, so I made the changes to my local system, pushed them to git, then cap production deploy. Once on the service I went to the current and ran rake db:migrate. Now when I visit my site I receive an error We're sorry, but something went wrong (500). There is no other information and my /opt/nginx/logs/error.log is completely blank. How do I fix this?
I'm using Postgresql, capistrano, rails 3, nginx
If you correctly installed ruby, rails, passenger and nginx, then follow my gist. You should go through the files and change the configuration according to your need. Here, you'll find
Gemfile // required gems for capistrano deployment
Capfile
deploy.rb // change the configuration for your server
production.rb // change the configuration for your server
After fully configured according to the gist, run
cap production deploy:check # it'll tell you what is missing for deploying your application
then, cap production deploy
Always check the production.log file if you facing any problem.
Using capistrano I'm deploying my Rails 4 app under the environment name "staging". When I ssh onto the server and run rails console, any ActiveRecord queries I do come up with no such table. So I check my Rails.env and sure enough it reads development instead of staging. But even running rails console staging, it does set Rails.env to "staging", but still the ActiveRecord queries say no such table. The app itself is running fine (under Apache and Passenger), but for some reason the rails console is unable to connect to the db.
I've reverted back to when I knew it was working and am still seeing the error, which tells me it is a configuration change i must've made on the server as opposed to a change to the rails app code or capistrano deploy config.
OK, tracked down the answer myself. The RAILS_ENV was originally being set to staging in /etc/environment -- but a while ago this file was removed during some debugging, and not restored.
What does still surprise me is that
rails console staging
does not have the same effect as
export RAILS_ENV=staging
rails console
anyhow, sorted.
I'm working on a project and I added a migration to add a project_page_description field to a Company Model. When I've ran the migrations,
#company = Company.first
#company.project_page_description
works locally, but any time I attempt to access project_page_description after deploying, I get an undefined method error. Why does it work locally but not remotely?
I've deployed all code so the codebases are identical, I've ran all migrations, I'm using Bundler and Capistrano, and I'm deploying to a CentOS server.
Also, besides stop programming, what can I do to stop this from happening again?
Looks like the migrations have not been run. Maybe you ran them using the development environment? Try running them like so: RAILS_ENV=staging bundle exec rake db:migrate.
Check your bundler groups, application config, and environment initializer files, maybe you have something defined as being development-only and not staging? Also try opening a console up on staging and trying to manually load and invoke the module that's not found. Remember that require returns true if the module was not already loaded.