NAME

Rex::Apache::Deploy::Symlink - Deploy application and symlink to live

DESCRIPTION

With this module you can deploy an application to a special folder and after that you can symlink it to the document root.

SYNOPSIS

generate_deploy_directory {
  my ($file) = @_;
  $file =~ m/(\d+\.\d+)/;
  return $1;
};

deploy_to "/data/myapp";
document_root "/var/www/html";

task "dodeploy", "server1", sub {
  deploy "myapp-1.2.tar.gz";
};

task "dodeploy", "server1", sub {
  deploy "myapp",
    version => "1.2";
};

FUNCTIONS

deploy($file, %option)

This function will do the deployment. It uploads the file to the target server and extract it to the directory given by deploy_to concatenated with the return value of generate_deploy_directory.

task "dodeploy", "server1", sub {
  deploy "myapp-1.2.tar.gz";
};

task "dodeploy", "server1", sub {
  deploy "myapp",
    version => "1.2";
};
list_versions

This function returns all available versions from the directory defined by deploy_to as an array.

switch_to_version($new_version)

This function switches to the given version.

task "switch", "server1", sub {
  my $param = shift;

  switch_to_version $param->{version};
};
get_live_version

This function returns the current live version.

deploy_to($directory)

This function sets the directory where the uploaded archives should be extracted. This is not the document root of your webserver.

deploy_to "/data/myapp";
document_root($doc_root)

This function sets the document root of your webserver. This will be a symlink to the deployed application.

generate_deploy_directory(sub{})

If you need a special directory naming of your uploaded version you can define it with this function.

The default function is:

sub {
  my ($file) = @_;
  if($file =~ m/-([0-9\._~\-]+)\.(zip|tar\.gz|war|tar\.bz2|jar)$/) {
    return $1;
  }
  else {
    return "" . time;
  }
};