{"id":24502758,"url":"https://github.com/sul-dlss/dlss-capistrano","last_synced_at":"2025-03-15T08:14:01.432Z","repository":{"id":18097672,"uuid":"21164755","full_name":"sul-dlss/dlss-capistrano","owner":"sul-dlss","description":"Capistrano extensions for DLSS","archived":false,"fork":false,"pushed_at":"2024-11-26T22:35:48.000Z","size":130,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":26,"default_branch":"main","last_synced_at":"2025-01-21T23:13:33.143Z","etag":null,"topics":["access","deployment","gem","infrastructure"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sul-dlss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-06-24T13:05:26.000Z","updated_at":"2024-11-26T22:35:17.000Z","dependencies_parsed_at":"2024-04-16T20:46:19.268Z","dependency_job_id":"b721f31f-7eef-4287-b3c3-238b97b80556","html_url":"https://github.com/sul-dlss/dlss-capistrano","commit_stats":null,"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sul-dlss%2Fdlss-capistrano","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sul-dlss%2Fdlss-capistrano/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sul-dlss%2Fdlss-capistrano/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sul-dlss%2Fdlss-capistrano/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sul-dlss","download_url":"https://codeload.github.com/sul-dlss/dlss-capistrano/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243701464,"owners_count":20333631,"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":["access","deployment","gem","infrastructure"],"created_at":"2025-01-21T23:13:51.333Z","updated_at":"2025-03-15T08:14:01.412Z","avatar_url":"https://github.com/sul-dlss.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dlss-capistrano\n\n[![Gem Version](https://badge.fury.io/rb/dlss-capistrano.svg)](https://badge.fury.io/rb/dlss-capistrano)\n\nThis gem provides Capistrano deployment tasks used by Stanford Libraries' Digital Library Systems and Services group.\n\n## Necessary Setup\n\nTo start, we recommend an SSH configuration like the one described in the [DeveloperPlaybook](https://github.com/sul-dlss/DeveloperPlaybook/blob/main/best-practices/ssh_configuration.md), since it has sensible defaults for Kerberos authentication and multi-factor authentication (using `ProxyJump` and `ControlMaster`, etc.).\n\nTo get `dlss-capistrano` tasks running via an existing SSH control master socket, you need to opt-in by setting the environment variable `USE_CAPISTRANO_CONTROLMASTER=true` (in e.g. your `~/.zshenv` file or similar for your particular shell).\n\nIf your SSH client configuration (`~/.ssh/config`) uses values other than the defaults for `CONTROLMASTER_HOST` (which maps to the `ProxyJump` directive, and defaults to `dlss-jump`) or `CONTROLMASTER_SOCKET` (which maps to the `ControlPath` directive, and defaults to `~/.ssh/%r@%h:%p`), you'll want to set these environment variables locally to the values you use (in e.g. your `~/.zshenv` file or similar for your particular shell). Otherwise, the gem will fail to connect to the appropriate jump host and/or won't be able to properly check the status of the control master process.\n\n## Included Tasks\n\n### Remote Execution\n\nSometimes you want to execute a command on all boxes in a given environment, and dlss-capistrano's got your back:\n\n```shell\n$ cap qa remote_execute[\"ps -ef | grep rolling | grep -v grep\"]\n00:00 remote_execute\n      ps -ef | grep rolling | grep -v grep\n      ps -ef | grep rolling | grep -v grep\n      dor-indexing-app-qa-a.stanford.edu:\ndor_ind+  9159     1 20 Feb18 ?        14:15:03 rolling index\n      dor-indexing-app-qa-b.stanford.edu:\ndor_ind+ 29689     1 20 Feb18 ?        14:24:53 rolling index\n```\n\n### Sidekiq symlink\n\nEvery time the version of Sidekiq or Ruby changes, a corresponding Puppet PR must be made in order to update the XSendFilePath that allows Apache to access the bundled Sidekiq gem's assets. dlss-capistrano provides a hook to create a symlink to the bundled Sidekiq to avoid having to do this:\n\n```ruby\nset :bundled_sidekiq_symlink, true # false is the default value\nset :bundled_sidekiq_roles, [:app] # this is the default value\n```\n\nSet this in `config/deploy.rb` to automate the symlink creation, and then use `XSendFilePath /path/to/my/app/shared/bundled_sidekiq/web/assets` in Apache configuration (in Puppet).\n\n### Status checking\n\n**NOTE**: Requires that `curl` is installed on each server host the check is run on.\n\nUse `cap ENV check_status` to hit the (_e.g._, [okcomputer](https://github.com/sportngin/okcomputer)-based) status endpoint of your application. This is especially valuable with hosts that cannot be directly checked due to firewall rules.\n\nBy default, these checks run against all nodes with the `:web` role and hit the `/status/all` endpoint. These can be configured in `config/deploy.rb` (or `config/deploy/{ENV}.rb` if you need environment-specific variation):\n\n```ruby\nset :check_status_roles, [:my_status_check_web_role]\nset :check_status_path, '/my/status/check/endpoint'\n```\n\n### Update global strscan gem\n\nThis insures the global version of strscan matches the version specified in the bundle.\n\nTo skip this step provide `SKIP_UPDATE_STRSCAN=1`\n\n### SSH\n\n`cap ENV ssh` establishes an SSH connection to the host running in `ENV` environment, and changes into the current deployment directory\n\n### SSH Connection Checking\n\n`cap ENV ssh_check` establishes an SSH connection to all app servers running in `ENV` environment and prints environment information to confirm the connection was made. This is used by [sdr-deploy](https://github.com/sul-dlss-labs/sdr-deploy/) to check SSH connections can be made in bulk before proceeding with a mass deploy.\n\n### Display Revision (and branches)\n\n`cap ENV deployed_branch` displays the currently deployed revision (commit ID) and any branches containing the revision for each server in `ENV`.\n\n### Sidekiq via systemd\n\n`cap ENV sidekiq_systemd:{quiet,stop,start,restart}`: quiets, stops, starts, restarts Sidekiq via systemd.\n\nThese tasks are intended to replace those provided by `capistrano-sidekiq` gem, which has assumptions about systemd that do not apply to our deployed environments.\n\n### Sneakers via systemd\n\n`cap ENV sneakers_systemd:{stop,start,restart}`: stops, starts, restarts Sneakers via systemd.\n\n### SolidQueue via systemd\n\n`cap ENV solid_queue_systemd:{stop,start,restart}`: stops, starts, restarts SolidQueue via systemd.\n\n### Racecar via systemd\n\n`cap ENV racecar_systemd:{stop,start,restart}`: stops, starts, restarts Racecar via systemd.\n\n#### Capistrano role\n\nThe sidekiq_systemd tasks assume a Capistrano role of `:app`. If your application uses a different Capistrano role for hosts that run Sidekiq workers, you can configure this in `config/deploy.rb`, _e.g._:\n\n```ruby\nset :sidekiq_systemd_role, :worker\n```\n\n#### Deployment hooks\n\nThe sidekiq_systemd tasks assume you want to hook them into Capistrano deployment on your own. If you want to use the hooks provided by `dlss-capistrano`, you can opt in via `config/deploy.rb`:\n\n```ruby\nset :sidekiq_systemd_use_hooks, true\n```\n\nThese are the hooks provided if you opt in:\n\n```ruby\nafter 'deploy:failed', 'sidekiq_systemd:restart'\nafter 'deploy:published', 'sidekiq_systemd:start'\nafter 'deploy:starting', 'sidekiq_systemd:quiet'\nafter 'deploy:updated', 'sidekiq_systemd:stop'\n```\n\n## Assumptions\n\ndlss-capistrano makes the following assumptions about your Ruby project\n\n- You are using Capistrano 3+\n- You use git for source control\n- The server you deploy to uses rvm, it is installed system-wide, and is the default system ruby\n- You do not have an .rvmrc checked into git (should be in your .gitignore)\n- You will not use rvm gemsets on the server you deploy to\n- Bundler will install specified gems into {your_project_home}/shared/bundle directory\n\n## Releasing\n\nTo release a new version:\n\n1. Update the version number in `dlss-capistrano.gemspec` and commit.\n2. `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.\n\n## Copyright\n\nCopyright (c) 2020 Stanford University. See LICENSE for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsul-dlss%2Fdlss-capistrano","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsul-dlss%2Fdlss-capistrano","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsul-dlss%2Fdlss-capistrano/lists"}