Project

kstrano

0.01
No commit activity in last 3 years
No release in over 3 years
Deploying symfony2 applications for the kDeploy server setup.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.2.1
>= 2.5.0
>= 1.6.6
>= 2.7.0
>= 3.5.5.38
 Project Readme

Introducing kStrano

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.

Prerequisites

Installing kStrano

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

Configuring your project

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

Available kStrano commands

  • 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

PHP recipe

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

Minimal setup

  • Add param to your github repo
  • Run ./param encode and add app/config/parameters.aes to your github repo
  • Commit the changes
  • Run cap deploy:setup

From now on you should be able to run cap:deploy to deploy the project...

Configuration

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.

Custom commands for PHP next to the one capifony makes available:

  • cap deploy:migrations, this will deploy and execute the pending migrations
  • cap deploy:schema:update, this will deploy and update the schema
  • cap deploy:clean, this will deploy without copying the vendors
  • cap deploy:prefer:source, this will deploy without copying the vendors and using composer option --prefer-source

Placing the site in Maintenance mode

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

Play recipe

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.

Available commands

  • cap play:start, this will start the play server
  • cap play:stop, this will stop the current play server

Drupal recipe

Magento recipe

Customizing the maintenance.html

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.

Changelog

  • 30/07/2014 (version 1.3.0)

  • Add gulp support

  • 19/06/2014 (version 1.2.0)

  • Add bundler support

  • 01/08/2013 (version 1.1.5)

  • revert changes from 23/07/2013

  • 23/07/2013 (version 1.1.4)

  • command added kuma:fpm:graceful_restart

  • commands removed kuma:apc:prepare, kuma:apc:clear

  • 22/07/2013 (version 1.1.3)

  • bower support disabled by default, added to your deploy.rb on 'kumafy .'

  • 10/07/2013 (version 1.1.0)

  • updated to work with Capifony 2.2.10

  • multiple recipes available for now play, symfony2

  • fix for clearing the APC cache

  • bower support

  • 13/02/2013 (version 0.0.30)

  • updated to work with Capifony 2.2.7

  • 24/08/2012 (version 0.0.21)

  • by default it works with Symfony version > 2.1 now, and it uses composer

  • kCapifony isn't needed anymore, from now on it works directly with Capifony

  • updated to work with the new version of Capifony

  • removed vendors from the shared folder to the release folder, and copy it with each deploy

  • clean up the gem no jenkins, campfire and airbrake support anymore

  • added extra commands like fpmreload, fpmrestart, apcclear

  • updated the default config files like: deploy.rb, staging.rb, production.rb, build.xml, etc.

  • fix to make the forward_agent working

  • small fixes

Analytics