
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
capistrano_multiconfig_parallel
Advanced tools
CapistranoMulticonfigParallel is a simple ruby implementation that allows you to run multiple tasks in parallel for multiple applications and uses websockets for inter-process communication and has a interactive menu
IMPORTANT! The whole reason for this gem was for using Caphub in a more easy way and allowing you to run tasks in parallel for multiple aplications . However this can be used for normal applications also, if you want for example to deploy your app to multiple sandboxes on development environment or even deploy in parallel to multiple stages.
CAUTION!! PLEASE READ CAREFULLY!! Capistrano is not thread-safe. However in order to work around this problem, each of the task is executing inside a thread that spawns a new process in order to run capistrano tasks The thread monitors the process. This works well, however if the tasks you are executing is working with files, you might get into deadlocks because multiple proceses try to access same resource. Instead of using files , please consider using StringIO instead.
Code for handling websocket events when a task is invoked was moved to a new gem capistrano_sentinel
You can now deploy applications from anywhere on your computer without having to add THIS gem to the Gemfiles of those applications, however we recommend you to add the capistrano_sentinel gem to those Gemfiles for better stability. The applications though must contain proper configuration for capistrano as you would normally do!!!
If capistrano_sentinel is included in one of the applications you are deploying, but you forget to require it, this gem will automatically patch the Capfile to require the gem. Otherwise the Capfile is not changed.
However this will work even if you don't add the capistrano_sentinel to your Gemfile, because the new version will automatically create three files "Gemfile.multi_cap", "Gemfile.multi_cap.lock" and "Capfile.multi_cap" where the dependency to capistrano_sentinel will be added and those new files will be used when deploying. This new Gemfile and the new Capfile will be clones of the original files, but will only add as dependency the capistrano_sentinel gem which is used to produce websocket events before a capistrano task is executed. And this gem will consume them and act depending on configuration.
After installing this gem locally on your system, you can just create anywhere on your computer a YAML file as described in section 2.2) Deploying multiple applications from a central location ( we suggest using the home directory) and then you can start deploying applications without adding new dependencies to those applications.
When the command will finish , the files created will be removed. ("Gemfile.multi_cap", "Gemfile.multi_cap.lock" and "Capfile.multi_cap") if they exist in the application root directory.
If you are using RVM and there is a .rvmrc file in your project root directory and bash is available , the script will use bash emulator in order to properly load RVM gemsets because .rvmrc files need trusting. If you use .rvmrc files please make sure you have the bash
executable available in your PATH . Please consider switching to .ruby-version and .ruby-gemset files instead which are faster and don't require trusting. You can read more about it here RVM Workflow
Dont use BUNDLE EXEC command when running the executable for this gem unless you are using version 1 or this gem is part of the Gemfile of the application you are using. Otherwise just use the multi_cap
executable without any prefix ( Unless this gem is part of your gemfile, in which case the BUNDLE EXEC prefix is needed )
Ruby 1.8, 1.9 are not officially supported.
Rubinius and Jruby support dropped.
Add the following to your Gemfile after requiring capistrano and capistrano-multiconfig:
gem "capistrano_sentinel"
Add the following to your Capfile after requiring capistrano and capistrano-multiconfig
require 'capistrano_sentinel'
Install locally on your system the capistrano_multiconfig_parallel gem using this command :
Please check first what is the last release here: Release Details and use that version instead of the one below
gem install capistrano_multiconfig_parallel -v 2.1.1
You will need to have MRI >= 2.2 when you install in this way due to activesupport dependency.
Or if you need to use MRI > 2.0 and < 2.2 you can use this command:
gem install capistrano_multiconfig_parallel # This will fail due to activesupport dependency, but next command will fix it
gem install capistrano_multiconfig_parallel:2.1.1 activesupport:4.0.0
You can replace the activesupport dependency with any version greater than 4.0 . I would suggest to use Ruby > 2.2.2 though.
For MRI > 2.0 and < 2.2 you can use though this workaround. Create a Gemfile on your sytem and add this line of code:
gem 'capistrano_multiconfig_parallel'
if RUBY_VERSION < "2.2.0"
gem 'activesupport', '>= 4.0', '< 5.0'
end
And use bundle exec multi_cap
from that directory when running the executable.
For Ruby >= 2.2 please use the first scenario and don't use BUNDLE EXEC in that case!!!
Please read Release Details if you are upgrading. We break backward compatibility between large ticks but you can expect it to be specified at release notes.
---
multi_debug: true
multi_secvential: false
check_app_bundler_dependencies: false
websocket_server:
enable_debug: false
adapter: ''
log_file_path: './log/multi_cap_websocket.log'
terminal:
clear_screen: false
development_stages:
- development
- webdev
apply_stage_confirmation:
- production
task_confirmations:
- deploy:symlink:release
application_dependencies: []
---
--multi-debug
--multi-secvential
--check_app_bundler_dependencies
--websocket_server.enable_debug
--websocket_server.adapter
--websocket_server.log_file_path
--terminal.clear_screen
--config_dir
--log_dir
--development_stages
--apply_stage_confirmation
--task_confirmations:
--application_dependencies
In order to override default configurations, you can either specify them at runtime using command-line , or you can create a file in location config/multi_cap.yml . This settings will be overriden by command line arguments( if any)
CapistranoMulticonfigParallel recognizes only "development" and "webdev" as stages for development if you use other stages for development, you need to configure it like this
---
development_stages:
- development
- webdev
- something_custom
----
# <box_name> - the name of a sandbox
#<development_stage> - the name of one of the stages you previously configured
#<task_name> - the capistrano task that you want to execute ( example: 'deploy' )
multi_cap <development_stage> <task_name> BOX=<box_name>,<box_name>
For Capistrano 2 application, the jobs will receive -S box=<box_name>,<box_name>, although you will use BOX when running the command. This so that i can maintain compatibility between versions
The script will ask if there are any other environment variables that user might want to pass to each of the sandboxes separately.
multi_cap deploy_multi_stages STAGES=development, staging, production
NOTE: IF you want to execute a different command on all stages, you can specify environment variable ACTION=task_name either when you specify the STAGES, or can be done individually for each task when prompted about additional ENV options
The script will ask if there are any other environment variables that user might want to pass to each of the stages separately.
If you use capistrano-gitflow, the workers will first deploy to all the other stages and only after staging is tagged , will trigger a new worker to start deploying to production
Configuration for this types of application is more complicated
---
application_dependencies:
- app: foo'
priority: 1
dependencies: []
- app: bar
priority: 1
dependencies:
- foo
- app: foo2
priority: 1
dependencies:
- foo
- bar
---
The "development_stages" options is used so that the gem can know if sandboxes are allowed for those environments.
The dependencies are being kept in the option "application_dependencies" This is an array of hashes. Each hash has only the keys "app" ( app name), "priority" and "dependencies" ( an array of app names that this app is dependent to)
In this example, if we execute this command:
multi_cap foo2:development deploy
Will ask user if he wants to deploy the apps "foo" and "bar" , since they appear in the dependencies list for the application "foo2"
multi_cap deploy_multi_stages STAGES=development, staging, production
Demo:
NOTE: IF you want to execute a different command on all stages, you can specify environment variable ACTION=task_name either when you specify the STAGES, or can be done individually for each task when prompted about additional ENV options
The script will ask for additional ENV options for each stage.
If you use capistrano-gitflow, the workers will first deploy to all the other stages and only after staging is tagged , will trigger a new worker to start deploying to production
This works like described in section 2) Multiple applications ), but now the application_dependencies Array can also have a path key inside each item that should point to the DocumentRoot of that application, and the configuration now accepts two new arguments config_dir ( this should point to the directory where the file multi_cap.yml resides) and log_dir( this can be used if you want your logs created in different directory)
This will only work if all applications listed in the configuration file have the gem capistrano_sentinel as part of their Gemfile.
Example of configuration: - create a directory anywhere (e.g.mkdir /tmp/app) - create a Gemfile and add only this two lines:
source 'http://rubygems.org'
gem 'capistrano_multiconfig_parallel'
or you could install it directly from command line:
gem install capistrano_multiconfig_parallel
Then create a file called multi_cap.yml in the root folder and create a configuration like this.
---
application_dependencies:
- app: foo'
priority: 1
path: /some/path/to/foo
dependencies: []
- app: bar
priority: 1
path: /some/path/to/bar
dependencies:
- foo
- app: foo2
priority: 1
path: /some/path/to/foo2
dependencies:
- foo
- bar
---
and then you can run like you would normally do: (Apppend bundle exec to the below command only if you have a Gemfile)
multi_cap foo2:development deploy
To test, do the following:
Please log all feedback/issues via Github Issues. Thanks.
== Copyright
Copyright (c) 2015 bogdanRada. See LICENSE.txt for further details.
FAQs
Unknown package
We found that capistrano_multiconfig_parallel demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.