Development

sfSyncClusterPlugin

You must first sign up to be able to contribute.

sfSyncClusterPlugin

Author

John L. Singleton
WordHustler? LLC
jsingleton@wordhustler.com
http://www.wordhustler.com

Overview

The sfSyncClusterPlugin introduces a symfony sync-cluster task. The symfony sync-cluster task is intended as a replacement for the symfony sync task. While the plugin is backwards-compatible with symfony sync (they even use the same configuration files) this plugin offers several advantages over a traditional symfony sync. The symfony sync-cluster task:

  • Synchronizes a Symfony application across an unlimited number of servers. Symfony's sync only works for a single server.
  • Clears the Symfony cache on each server with a symfony cc. Doing this with sync requires an additional command.
  • Allows you to use ssh public/private keyfile authentication so you won't be prompted for a password during long deployments.

Installation

To install sfSyncClusterPlugin:

Listing 1 - Installing sfSyncClusterPlugin

symfony plugin-install http://plugins.symfony-project.com/sfSyncClusterPlugin
symfony cc

You can now use the symfony sync-cluster task.

Usage

The sync-cluster task behaves exactly as sync. For more information about using symfony sync, please see the Application Management section of the Symfony documentation.

To configure sfSyncCluster, you must edit your project's properties.ini file. Below is an example that contains a complete sfSyncCluster configuration.

Listing 2 - Example sfSyncCluster configuration in myproject/config/properties.ini.

[symfony]
  name=MyApplication
[production]
  host=domain.com
  cluster=node1.domain.com, node2.domain.com, node3.domain.com
  keyfile=/Users/johndoe/keys/id_rsa
  port=22
  user=root
  dir=/var/www/html/MyApplication/

The settings you need to activate for sfSyncCluster are cluster and optionally, keyfile. The host parameter is ignored. To use this plugin, simply invoke the task from within a project.

Listing 3 - Using the sync-cluster task

/* does a dry run */
# symfony sync-cluster production

/* does it for real */
# symfony sync-cluster production go

Note that in order for sfSyncCluster to work, your servers must share the same filesystem structure for your application. For example, if dir is set to /foo/bar/myApplication/ the sync-cluster task will try to synchronize with the application at /foo/bar/myApplication/ on every server. Be warned.

License

For the full copyright and license information, please view the LICENSE file that was distributed with this source code.

Change Log

5/02/08 -- Initial Release.

Attachments