Commit Graph

66 Commits

Author SHA1 Message Date
Javi Martín
e1e2329189 Specify which bundler version to install
We're now using the same version we used to generate our Gemfile.lock.

Using the latest bundler we got a deprecation warning, which might turn
into an error in the future:

[DEPRECATED] The `--deployment` flag is deprecated because it relies on
being remembered across bundler invocations, which bundler will no
longer do in future versions.

We could also upgrade to bundler 2.x, but since we're using Ruby 2.4 and
Ruby 2.6 comes with bundler 1.17, we've decided to keep this version.
2020-02-27 17:33:21 +01:00
Javi Martín
755bc8e88a Restart the application on deploy:restart
The task `deploy:restart` was doing nothing since we moved from unicorn
to puma.

Now we're also restarting delayed jobs on `deploy:restart`, which is
probably what's expected in most cases.
2019-11-17 22:55:42 +01:00
Javi Martín
69b4740ec8 Remove redundant cleanup task
Capistrano automatically runs `deploy:cleanup` after finishing.
2019-11-17 22:55:27 +01:00
Javi Martín
6b5d25b28e Update Ruby after deploy:updating
We need to download the most recent CONSUL and check its `.ruby-version`
file before installing Ruby.

The `rvm1-capistrano` gem knows it and was invoking the `updating` task
before installing Ruby. So we were getting a warning in Capistrano about
the `updating` task being executed twice.
2019-11-17 17:17:17 +01:00
Javier Martín
6c80da71ad Merge pull request #3853 from consul/fix_first_deployment
Fix secrets task on first deployments
2019-11-14 13:32:32 +01:00
Javi Martín
0c33c4061d Fix secrets task on first deployments
New CONSUL instances who didn't use the newest installer and haven't
done any deployments with capistrano would get an exception because the
`current` capistrano folder doesn't exist yet.
2019-11-14 00:15:19 +01:00
Javi Martín
1e32455cd9 Add puma configuration to version control
We were using Capistrano's shared folder because it was the default
folder used by the capistrano-puma gem. However, it's easier to manage
it if it's under version control.

So we're moving the old `puma.rb` to `puma/development.rb`, and we use
the new `puma.rb` file for all environments except development. Anyone
installing CONSUL can change these files at will or change the specific
files for preproduction, production and staging environments.
2019-11-13 13:28:27 +01:00
Javi Martín
82e96edf1f Remove duplication in deploy environment files
Deploy environment files were loaded after config/deploy.rb was loaded,
meaning if we used settings like `deploy_to` or `current_path` to set
variables inside the config/deploy.rb file, we'd be using the default
settings instead of the ones dictated by the deploy environment files.
2019-11-12 20:20:45 +01:00
Javi Martín
95d395343b Use two puma workers
This is the same configuration we had with unicorn.

With several workers, we've got two basic configuration options:

* Preload the application and use a hot restart
* Don't preload the application and use a phased restart

I've decided to preload the application because using a hot restart
changes are available immediately, while with a phased restart there are
a few seconds when both workers for the old code and workers for the new
code exist.

Using a phased restart also has advantages, so some forks might want to
disable the `puma_preload_app` setting in order to use it.
2019-11-12 15:32:04 +01:00
Javi Martín
d17b2523cf Make puma restarts work with systemd
Just like mentioned in puma's documentation:

https://github.com/puma/puma/blob/master/docs/systemd.md#socket-activation
2019-11-12 15:32:04 +01:00
Javi Martín
d7aab4c929 Check permissions for secrets file
Old versions of the installer created this file as root, making it
impossible to change it as a regular user.

So for old installations we need to make sure we've got write access to
this file.

We're using `sudo` because in these applications the installer gives
`sudo` access to the deploy user, so everything works fine with the
default configuration.
2019-11-12 14:58:35 +01:00
Javi Martín
a08d42d3f8 Enable/disable delayed jobs in the secrets file
While this is not a secret and in theory should be in a file under
version control, currently the CONSUL installer disables delayed jobs by
default, meaning we were keeping two versions of the delayed jobs
configuration file, and some existing configurations have their settings
defined in a file in capistrano's `shared` folder.

So we're moving existing settings to the secrets file.
2019-11-12 14:58:35 +01:00
Javi Martín
6ecd9e59dc Update secrets based on the previous release
We were copying the current SMTP and SSL settings to the secrets file
after overwriting them, but we need to copy them before overwriting
them.

The workaround I've found is to copy the tasks to the folder of the
previous release and execute them there.
2019-11-12 14:58:06 +01:00
Julian Herrero
d6130cf6e2 Add task to move force_ssl settings to secrets.yml
Existing installations having their configuration settings in the
capistrano shared folder needed this migration.
2019-11-12 14:58:05 +01:00
Javi Martín
03c4275525 Add task to move SMTP settings to secrets.yml
Existing installations having their configuration settings in the
capistrano shared folder needed this migration.

Note we can't just use `YAML.load` because we'd lose the anchors defined
in the file. So we have to parse the file the hard way.
2019-11-12 14:47:27 +01:00
Javi Martín
bc9471b49e Define SMTP configuration in the secrets file
Since SMTP passwords should not be in a file under version control, and
they're usually configured in the production.rb file (which is under
version control), the natural place to configure it is the secrets.yml
file.

Until now we were using the capistrano shared folder, but that's a bit
inconvenient since changes we've done to the production.rb file (like
changing eager_load_paths when we upgraded to Rails 5) won't take effect
after a deployment.
2019-11-11 12:11:20 +01:00
Senén Rodero Rodríguez
15b4ff64f4 Run local census records remove_duplicates rake task during deployment
... and before applying new migrations.
2019-11-08 14:46:45 +01:00
Javi Martín
41d252bf10 Simplify syntax to execute RMV
We use `:rvm` just as we use `:rake` in other places.
2019-10-13 00:31:13 +02:00
Javi Martín
48dd4be851 Use .ruby-version to detect our Ruby version
Travis and Rubocop and rmv1-capistrano3 automatically detect the version
based on the `.ruby-version` file.
2019-10-13 00:31:13 +02:00
Javi Martín
19f8e3ac8e Enable tasks to install Ruby and bundler
We're going to upgrade our ruby version, and we need these tasks.

Note we now get a warning caused by `rvm1:install:ruby` invoking
`deploy:updating`. It doesn't seem to be an issue because we don't add
any hooks to `deploy:updating`, and neither do the rest of the gems we
use.
2019-10-13 00:28:33 +02:00
Javi Martín
f26f8b3c3e Add support for legacy unicorn installations
Old CONSUL nginx configurations will probably have a reference to a
unicorn socket. Making that file a symbolic link to a puma socket makes
it possible for the application to keep working without updating the
nginx configuration file.
2019-10-12 17:01:15 +02:00
Javi Martín
3b79a1a3db Add compatibility between puma and RMV1
Puma was adding commands to `rvm_map_bins`, which meant RMV1 wasn't
using the default value of `rvm1_map_bins`.

Changing the order we use to require `rmv1/capistrano3` and
`capistrano/puma` did not fix the issue.
2019-10-12 16:51:28 +02:00
Javi Martín
b36e659f4e Use puma instead of unicorn
Puma is the server we use in the development environment, so this way we
don't need to maintain two servers. Furthermore, puma seems to offer a
few advantages over unicorn (like multithreading) and no disadvantages.
2019-10-12 16:50:49 +02:00
Javi Martín
488461b8ac Remove consecutive blank lines 2019-09-10 20:02:15 +02:00
Javi Martín
b5b07bccd3 Apply PercentLiteralDelimiters rubocop rule 2019-09-10 20:02:15 +02:00
Javi Martín
d2c075cc93 Add new settings on servers with the db role
This task adds records to the database, so the role `db` is more
appropriate.
2019-06-05 20:23:56 +02:00
Javi Martín
685c96c40d Add capistrano task to deploy and upgrade CONSUL 2019-06-05 20:23:56 +02:00
Javi Martín
e339ed94d1 Add new settings every time we deploy
This way we don't need to add and execute rake tasks every time we add a
new setting.
2019-05-31 19:33:31 +02:00
Julian Nicolas Herrero
d83bf940be Merge pull request #3370 from consul/double_quoutes_everywhere
Change single quotes to double quotes everywhere
2019-03-19 12:20:16 +01:00
Julian Herrero
c9cdc72537 Use double quotes in config/ 2019-03-15 10:29:07 +01:00
Julian Herrero
63182569f4 Keep images uploaded with CKEditor when deploying
Images uploaded with CKEditor go to a folder that was not linked, so
every new deploy with capistrano the reference to those images was
lost.

By linking the directory the references to the images remain after a
new deploy.
2019-03-14 15:57:26 +01:00
voodoorai2000
bebcc3da48 Skip ruby and bundler installations
Ruby and bundler should already be installed in the system

Before we can bring back these commands we need to review them, right now they are raising an interesting exception
2018-09-21 15:31:40 +02:00
voodoorai2000
335cd2b597 Link unicorn and production.rb to capistrano's shared folder 2018-09-21 15:29:57 +02:00
Bertocq
0ecfbfe55c Fix capistrano version lock on deploy.rb script to same on Gemfile 2018-01-07 12:51:42 +01:00
Juanjo Bazán
ab2391b78d adds sitemap updating task to deploy 2017-06-06 12:25:45 +02:00
Juanjo Bazán
29e5cff13f updates capistrano 2017-05-01 12:20:52 +02:00
kikito
1d456b0459 updates capistrano to match the Gemfile 2017-04-04 13:20:45 +02:00
Juanjo Bazán
2d3e3586d1 updates capistrano scm config 2017-03-14 13:30:31 +01:00
rgarcia
d0b0782c46 sets only one server to run delayed jobs 2016-12-28 21:24:56 +01:00
rgarcia
5d6c083f67 updates sitemap daily in all servers 2016-12-04 19:57:10 +01:00
rgarcia
cea90fea47 installs bundler gem for new ruby versions 2016-11-21 10:15:57 +01:00
rgarcia
d24ef1615f cleans up deploy.rb 2016-11-21 10:15:51 +01:00
rgarcia
c8c5b55816 updates ruby version for capistrano 2016-11-21 10:15:44 +01:00
rgarcia
a1095089af configures up to date capistrano rvm gem 2016-11-21 10:15:34 +01:00
Juanjo Bazán
f91385873a updates ruby version in deploy.rb to 2.3.1 2016-07-12 11:21:15 +02:00
Juanjo Bazán
575d9a1998 updates capistrano 2016-07-11 14:21:54 +02:00
kikito
62745136db Fixes capistrano setup mismatch 2016-04-25 15:14:44 +02:00
Juanjo Bazán
b946f31fc7 changes 'participacion' to 'consul' in config 2015-11-23 14:10:46 +01:00
Juanjo Bazán
7a5454da68 updates consul url 2015-11-20 20:09:24 +01:00
Juanjo Bazán
1e0ac137bb removes beta testers functionality 2015-10-29 13:19:00 +01:00