Skip to content

Commit

Permalink
Allow capistrano to open up the application on the servers (#1816)
Browse files Browse the repository at this point in the history
This allows us to see how a specific server looks without having to go through the load balancer

Co-authored-by: Bess Sadler <[email protected]>
  • Loading branch information
carolyncole and bess authored May 23, 2024
1 parent a2960eb commit f735794
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ Look in your default browser for the consoles
### Mail on Production
Emails on production are sent via [Pony Express](https://github.com/pulibrary/pul-it-handbook/blob/f54dfdc7ada1ff993a721f6edb4aa1707bb3a3a5/services/smtp-mail-server.md).

### Admin users in Production
## Admin users in Production
To add a new user as an admin (e.g., so they can migrate data from DataSpace), use the rails console on the production system:
```
irb(main):010:0> user = User.find_by(uid: 'hb0344')
irb(main):015:0> user.add_role(:group_admin, Group.plasma_laboratory)
irb(main):016:0> user.add_role(:group_admin, Group.research_data)
```

### PPPL submitters
## PPPL submitters
To allow a non-admin user to submit only to the PPPL group and its communities and subcommunities, that user's default Group must be set to the Princeton Plasma Physics Lab and their roles must be updated. To do this, use the Rails console:
```
irb(main):011:0> user = User.find_by(uid: 'hb0344')
Expand All @@ -131,3 +131,18 @@ irb(main):013:0> user.add_role(:submitter, Group.plasma_laboratory)
irb(main):014:0> user.remove_role(:submitter, Group.research_data)
irb(main):015:0> user.save!
```

## Viewing the Application outside of the load balancer
To view the application on a specific server you can utilize capistrano to tunnel into the server and open up a browser.

The following would open up a browser to the web application after deploying. This will allow the developer to verify that the deployment was successful prior to deploying the secondary.
```
cap production_primary application:webapp
```

## Rolling deployments to production
We utilize rolling deployments to production. When a new release is ready to deploy
1. deploy to production_primary via [ansible tower](https://ansible-tower.princeton.edu/#/templates)
1. verify that the deployment was successful utilizing capistrano `cap production_primary application:webapp`
1. deploy to production_secondary via [ansible tower](https://ansible-tower.princeton.edu/#/templates)
1. verify that the deployment was successful utilizing capistrano `cap production_secondary application:webapp`
18 changes: 18 additions & 0 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@
end
end

namespace :application do
desc "Opens the application web app without the load balancer"
task :webapp do
on roles(:app) do |host|
app_host = host.hostname
user = "pulsys"
port = rand(9000..9999)
puts "Opening #{app_host} application on port #{port} as user #{user}"
Net::SSH.start(app_host, user) do |session|
session.forward.local(port, "localhost", 80)
puts "Press Ctrl+C to end the application connection"
`open http://localhost:#{port}/describe`
session.loop(0.1) { true }
end
end
end
end

before "deploy:reverted", "deploy:assets:precompile"

# rubocop:enable Rails/Output

0 comments on commit f735794

Please sign in to comment.