After setup Delayed_job in development, here is the file delayed_job in /bin directory. When I deploy project to server, the file delayed_job just disappears.
Since you've found that the bin folder is sym-linked to a shared/bin folder (on deploy?) you'd need to scp your delayed_job executable into the shared/bin folder on server at this point. Or you may be able to do this on deploy just before the point in the cap deploy files where the symbolic link is made. Or perhaps just do it once now (and again in the future as needed) and then add the bin folder to your .gitignore. In fact I'd recommend this latter approach in case you start using spring with binstubs in development (as you wouldn't want these special executables being copied up to your server for production mode).
Related
Everytime that the carrierwave save a file, go to app/public folder, and the tmp and log folder get bigger overtime, so, is possible to make these folder outside the RailsApp?
change the Rails.root.join("") on the application.rb is the only way to do it?
on mina deploy is possible to create shared_path if created ouside have to symlink the path?
If you are deploying on a *nix box then symlinks are the way to go. I haven't used Mina, but if you deploy with Capistrano then you can script re-creation of whatever symlinks are needed fairly easily.
Just looking at the Mina page, you should be able to write a task to re-create your symlinks on deploy:
writing_your_own_tasks
I am totally new to rails deployment. After googling, I still find it hard to understand how to deploy rails apps.
So, my questions are:
After setting up the VPS with all rails dependencies, where do I store my codebase? The root directory of the VPS or some specific locations e.g. www/ or public/?
Should I upload the whole rails app folder or just part of it? I have paperclip in my rails app, and paperclip creates a system/ directory in the public/ folder, so should I upload system/?
In Capistrano 3, there is a repo_url field, I know they support file://, https://, ssh://, or svn+ssh://, but most of the articles about capistrano put github repositories into that. However, I do not have such a github repo. What should I input then?
Thank you for your attention.
Answers to the specific questions raised:
After setting up the VPS with all rails dependencies, where do I store
my codebase? The root directory of the VPS or some specific locations
e.g. www/ or public/?
It will be deployed to the folder pointed by :deploy_to parameter. If not specified, :deploy_to defaults to /var/www/#{fetch(:application) See: https://github.com/capistrano/capistrano/blob/05f63f5f333bb261f2a4c4497174361c48143252/lib/capistrano/defaults.rb#L3
Should I upload the whole rails app folder or just part of it? I have
paperclip in my rails app, and paperclip creates a system/ directory
in the public/ folder, so should I upload system/?
Paperclip system folder is specific to the environment; each environment (development, production,...) will have its own system folder which will store the files uploaded on that specific environment. This folder should not be part of the code being deployed.
The recommended way of handing such folders is the keep them in a shared folder on the server, and create symlinks in the current version of the code so that the same folder is used for storing/retrieving attachments. See Section 3. Update custom links section in http://robmclarty.com/blog/how-to-deploy-a-rails-4-app-with-git-and-capistrano for more details about this.
As mentioned there, the same applies to config/database.yml file, and any other file containing environment specific configurations.
In Capistrano 3, there is a repo_url field, I know they support
file://, https://, ssh://, or svn+ssh://, but most of the articles
about capistrano put github repositories into that. However, I do not
have such a github repo. What should I input then?
Depends on where the code you are deploying is stored. If it is in a local folder, use the file::// format to specify where the files are located.
You can set up your own private git server, then in deploy.rb you can put something like
set :repo_url, 'ssh://user#server_ip/path/to/your_git_repo.git'
When you commit your changes to the git repo, you do not have to upload the app to the server. Capistrano will upload the app for you when you deploy.
where do i put my code base? This is determined by what you put in deploy.rb e.g
set :deploy_to, '/path/to/my_codebase'
Whether to upload the /system directory will depend on whether you want the paperclip images on your version control. If not you can add the directory to gitignore. Here is a tutorial on how to deploy on ubuntu 14.04 passenger and NGINX. if you are not using Passenger and Nginx you can skip to how to configure capistrano and make adjustments depending on your setup.
EDIT
You need to install git on your development machine and set up a git server on your VPS as explained on the link above, add your remote server to your local machine using
git remote add origin <server>
where 'server' is the url to your git repo in the VPS e.g.
ssh://VPS_user#VPS_ip/path/to/your_git_repo.git
Now when you commit and push your changes to the server, capistrano will deploy the latest version on your git server.
Here is a link with a guide on how to get started with git
I'm running Capistrano 3 in a Rails 4 app, and have a non-bundler binstub in my bin directory (delayed_job). The binstub is checked in to my repository, and I can see it on GitHub. However, when I deploy (using capistrano-bundler), the bin/delayed_job file isn't pushed to the server.
I tried add this to my config/deploy.rb file, but it didn't affect anything:
set :bundle_bins, fetch(:bundle_bins, []).push('bin/delayed_job')
Is there something else I need to do to make sure the binstub ends up on the server?
please check if you have added "bin" folder into "linked_dir" call of your Capistrano script.
If you have added then you have to copy file to the server into location your_app/shared/bin/
If not then it will work by check in that file into repository.
I'm a little confused how I can have different versions of .rvmrc files on my local laptop and on my server when I am using capistrano for deployment.
Since it pulls from my GIT, how can I manage both files?
I just add it to my .gitignore after I pull it down the first time.
I'm uploading files to my public/files folder of a Rails application on a constant basis through a web interface.
I don't want to keep these in source control since they go for almost 2 GBs, so every time I do a cap deploy it will save those files away in releases/ and replace the directory with the pristine copy stored in the repository.
I'm wondering what's the best way to keep those files in the server, in the current directory. Some of my ideas are:
Remove the directory from source control and replace it with a link to an external directory that's not managed by Capistrano.
Create a Capistrano task to copy the directory to /tmp before deploying and then copying it back to /public after it's done deploying.
Is there standard way to do this?
For the future record, this is the task I used to do it with a shared directory:
task :link_shared_directories do
run "ln -s #{shared_path}/files #{release_path}/public/files"
end
after "deploy:update_code", :link_shared_directories
You could make files a symlink to another directory on your machine, for examples the /shared directory at the same level as /current and /releases.
Check out capistrano manages the /log and /tmp directories.
Now we can simply use :linked_files in deploy.rb:
set :linked_files, %w{config/database.yml}
In this case, the file [target_dir]/shared/config/database.yml must exist on the server.