{"id":18449541,"url":"https://github.com/jetthoughts/j-cap-recipes","last_synced_at":"2025-04-08T01:33:00.458Z","repository":{"id":11507961,"uuid":"13987254","full_name":"jetthoughts/j-cap-recipes","owner":"jetthoughts","description":null,"archived":false,"fork":false,"pushed_at":"2015-03-08T14:47:09.000Z","size":658,"stargazers_count":5,"open_issues_count":2,"forks_count":6,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-03-23T03:51:19.869Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jetthoughts.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-30T13:30:18.000Z","updated_at":"2015-03-08T14:47:05.000Z","dependencies_parsed_at":"2022-09-22T23:21:42.452Z","dependency_job_id":null,"html_url":"https://github.com/jetthoughts/j-cap-recipes","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jetthoughts%2Fj-cap-recipes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jetthoughts%2Fj-cap-recipes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jetthoughts%2Fj-cap-recipes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jetthoughts%2Fj-cap-recipes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jetthoughts","download_url":"https://codeload.github.com/jetthoughts/j-cap-recipes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247760756,"owners_count":20991530,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T07:20:32.696Z","updated_at":"2025-04-08T01:33:00.243Z","avatar_url":"https://github.com/jetthoughts.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Capistrano::Recipes\n[![Gem Version](https://badge.fury.io/rb/j-cap-recipes.png)](http://badge.fury.io/rb/j-cap-recipes)\n\nA simple number of capistrano recipes to deploy rails application using Capistrano v3.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'j-cap-recipes', group: :development\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install j-cap-recipes\n\n## Usage\n\nIn the `Capfile` to include all recipes add:\n\n    require 'j-cap-recipes/default'\n\nIf you want to load only specified recipe:\n\n    require 'j-cap-recipes/setup'\n    require 'j-cap-recipes/check'\n    require 'j-cap-recipes/nginx'\n    require 'j-cap-recipes/monit'\n    require 'j-cap-recipes/database'\n    require 'j-cap-recipes/delayed_job'\n    require 'j-cap-recipes/log'\n    require 'j-cap-recipes/rails'\n    require 'j-cap-recipes/unicorn'\n    require 'j-cap-recipes/honeybadger'\n    require 'j-cap-recipes/airbrake'\n\nAlso you need to include rake tasks in your `Rakefile`:\n\n    require 'j-cap-recipes'\n\n### Nginx\n### Setup\n### Check\n### Monit\n\n### Database recipes\n\n `cap production db:create`\n `cap production db:backup`\n `cap production db:dump_download`\n `cap production db:dump_download[rails_env]` - Download the file that located in `\u003ccurrent\u003e/db/backups/\u003capplication\u003e_\u003crails_env\u003e_latest.dump`\n `cap production db:dump_upload`\n `cap production db:dump_upload[rails_env]` - Upload the file `\u003ccurrent\u003e/db/backups/\u003capplication\u003e_\u003crails_env\u003e_latest.dump` to remote host\n `cap production db:restore`\n\n\n### Rails\n\nTo run remote rails console you should update to the latest gems `capistrano-rbenv` and `capistrano-bundler`\nand run command `cap production rails:console`.\n\nTo setup a custom `database.yml` config you should provide the directory of the templates\n\n```ruby\nset :template_dir, `config/deploy/templates`\n```\n\nAfter you should create a file `database.yml.erb` example:\n\n```yaml\n# store your custom template at foo/bar/database.yml.erb `set :template_dir, \"foo/bar\"`\n#\n# example of database template\n\nbase: \u0026base\n  adapter: postgresql\n  encoding: unicode\n  timeout: 5000\n  username: deployer\n  password: \u003c%#= ask(:db_password, SecureRandom.base64(6)) \u0026\u0026 fetch(:db_password) %\u003e\n  host: localhost\n port: 5432\n\ntest:\n  database: \u003c%= fetch(:application) %\u003e_test\n  \u003c\u003c: *base\n\n\u003c%= fetch(:rails_env).to_s %\u003e:\n  database: \u003c%= fetch(:application) %\u003e_\u003c%= fetch(:rails_env).to_s %\u003e\n  \u003c\u003c: *base\n\n```\n\n### Honeybadger\n\n`honeybadger:deploy` - notify the service about deploy and it would be invoked after `deploy:migrate`\n\n### Settings\n\nSupport to manage https://github.com/bigbinary/handy config files. First should add `require 'j-cap-recipes/settings'` to `Capfile`.\nThere are tasks available:\n\n- `cap staging config:settings` Show the current staging config files;\n- `cap staging config:settings:delete` Remove the custom env settings file;\n- `cap staging config:settings:upload` Update the remote config file with local one;\n- `cap staging config:settings:get` Download the remote config file to local one\n- `cap staging config:settings:edit` Direct editing of the settings file\n\n### Update VERSION file with build number\n\nTask `deploy:update_version` adds to end of line the `:build_number` string. You may set it to:\n\n```ruby\nset :build_number, proc { [fetch(:current_revision), Time.now.strftime(\"%Y%m%d\"), ].compact.join('-') }\nset :version_filename, 'VERSION'\n```\n\n### Git\n\nFirst should add `require 'j-cap-recipes/git'` to `Capfile`.\n- `cap staging git:release:tag` Create tag in local repo by variable `git_tag_name`\n Example of usage in your `deploy.rb`:\n\n```ruby\nset :git_tag_name, proc { Time.now.to_s.gsub(/[\\s\\+]+/, '_') }\nafter 'deploy:finished', 'git:release:tag'\n```\n\n### Files\n\nAdd 'j-cap-recipes/git'` to `Capfile`.\nAnd now you have task to download any remote file to local via:\n`bundle exec cap staging \"files:download[config/database.yml]\"`.\nYou will find `download.tar` file in current directory with `config/database.yml`.\n\nTo download all share folder use:\n`bundle exec cap staging \"files:download[.]\"`\n\nTo extract the archive `tar -xvf download.tar -C tmp`\n\n### Airbrake\n\nAdd 'j-cap-recipes/airbrake'` to `Capfile`. The original version capistrano task to notify airbrake service support only\nCapistrano version 2. Migrate the task to support version 3.\n\nTo send Airbrake deploy notification, you should also add hook to `deploy.rb`\n\n```ruby\nafter 'deploy:finishing', 'airbrake:deploy'\n```\n\nYou can change the default api key using `ENV['API_KEY']`.\n\n\n### Rake tasks\n\nAdded utility rake task to create database backup for postgresql and rails.\n\n### SSHKit addon\n\n`SSHKit::Backend::SshCommand` a new backend to invoke the ssh command using system command `ssh`.\nNow you can easy to execute interactive applications with similar changes. Example:\n\n```ruby\nnamespace :rails do\n  desc 'Execute rails console'\n  task :console do\n    on roles(:app), in: :parallel, backend: :ssh_command do |*args|\n      within release_path do\n        with rails_env: fetch(:rails_env) do\n          execute(:rails, :console)\n        end\n      end\n    end\n  end\nend\n```\n\nAnd you have a easy and fast way to run remote interactive rails console via command `cap production rails:console`.\n\n```ruby\ntask :less_log do\n  on roles(:app), in: :parallel, backend: :ssh_command do |*args|\n    within current_path.join('log') do\n      execute(:less, '-R', fetch(:rails_env)+'.log')\n    end\n  end\nend\n```\n\nAnd you have way to look to logs `cap production less_log`.\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjetthoughts%2Fj-cap-recipes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjetthoughts%2Fj-cap-recipes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjetthoughts%2Fj-cap-recipes/lists"}