Capistrano is an open source tool for running scripts on multiple servers. It’s primary use is for easily deploying applications. kStrano (KumaStrano) is a deployment “recipe” to work with Kunstmaan specific applications to make your job a lot easier.
Before you install make sure you have no older versions of kStrano or Capifony:
gem uninstall kstrano
You can install kStrano using rubyGems:
gem install kstrano
gem cleanup railsless-deply, capifony, capistrano
Or you can download the source and install it manually:
gem build kstrano.gemspec
gem install kstrano-<version>.gem
cd to/your/project/path
kumafy .
You can also do a force install, which will update all the files:
cd to/your/project/path
kumafy . --force
cap kuma:fix:cron, this will run the fixcron command on the server from kDeploy.
cap kuma:fix:perms, this will run the fixperms command on the server from kDeploy.
cap kuma:fpm:reload, this will reload fpm on the server.
cap kuma:fpm:restart, this will restart fpm on the server.
cap kuma:fpm:graceful_restart, this will restart fpm on the server gracefully.
cap kuma:apc:clear, this will clear the apc cache.
cap kuma:changelog, this will show the log of what changed compared to the deployed version
cap kuma:sync, this will sync the database and rsync the uploaded files from online to local
cap files:move:to_local, this will rsync the uploaded files from online to local
The PHP recipe is based on Capifony, and it adds a few things to make it work with our hosting platform at Kunstmaan.
by default the configuration files are made for Symfony version > 2.1, and they use composer. To make it work with a version without composer change
set :use_composer, true
set :update_vendors, false
to
set :use_composer, false
set :vendors_mode, "install"
set :update_vendors, true
in your deploy.rb
cap deploy:setup
From now on you should be able to run cap:deploy
to deploy the project...
kStrano specific configuration options
set :force_schema, false # when true, schema:update will be run (see gem deploy:schema:update)
set :force_migrations, false # when true, migrations will be run (see gem deploy:migrations)
set :bundler_install, true # when true, bundler will run an install
set :npm_install, true # when true, npm install will be run after composer install
set :bower_install, true # when true, bower install will be run after npm install
set :grunt_build, true # when true, grunt build will be run after bower install
set :gulp_build, false # when true, gulp build will be run after bower install
These options are on by default, you can overwrite these in your deploy.rb or by running your cap deploy with -s (ex. cap deploy -s force_schema=true)
The following defaults of Capifony are set in kStrano:
set :copy_vendors, true # when true, vendors will be copied from a previous release
set :dump_assetic_assets, true # when true, use the assetic bundle
set :interactive_mode, false # when false, it will never ask for confirmations (migrations task for instance)
set :clear_controllers, true # when true, removes the app_*.php files from web/
set (:symfony_env_prod) {"#{env}"} # the symfony environment variable is set to what's configured in env
set :uploaded_files_path, 'web/uploads' # the path where your files are uploaded
For further configuration options see Capifony.
To place the site in maintenance mode, we first need to edit the htaccess file to redirect users to the maintenance page. Place the following snippet in your htaccess file.
ErrorDocument 503 /maintenance.html
RewriteBase /
RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png|js)$
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{ENV:REDIRECT_STATUS} !=503
RewriteCond %{REMOTE_ADDR} !^#Place the allowed ip addresses here (e.g. 127\.0\.0\.1)
RewriteRule ^.*$ - [R=503,L]
This will present the maintenance page to the user if the maintenance.html file is present and the user's IP is not allowed. To place the site in maintenance mode, issue the next command. This command will create a maintenance.html file in your data/releases/*/web directory
cap deploy:web:disable
In order to place the site out of maintenance mode, issue the next command. This command will remove the created maintenance.html file that was created by the previous command.
cap deploy:web:enable
The play recipe is a very simple recipe which is based on railsless-deploy and adds tasks to package the app, start and stop the server.
If you want newrelic support, make sure you put the jar in newrelic/newrelic.jar.
The standard maintenance.html page just states that the site is in maintenance and will be back shortly. In order to have a custom maintenance page, you need to set the maintenance_template_path in your deploy.rb.
set :maintenance_template_path, "location of your custom template"
Now you will see your own custom maintenance page. Note that the deploy:web:disable command copies the content from the template to the maintenance.html file. So you can not use relative paths in your custom template if you want to show images, custom css etc.
30/07/2014 (version 1.3.0)
19/06/2014 (version 1.2.0)
01/08/2013 (version 1.1.5)
23/07/2013 (version 1.1.4)
22/07/2013 (version 1.1.3)
10/07/2013 (version 1.1.0)
13/02/2013 (version 0.0.30)
24/08/2012 (version 0.0.21)