Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guitarrapc/3ef1cc33dc13ef0f3776 to your computer and use it in GitHub Desktop.
Save guitarrapc/3ef1cc33dc13ef0f3776 to your computer and use it in GitHub Desktop.
Automate Deploy S3 placed TopShelf Application to the host
configuration SampleTopShelfContinuousDelivery
{
$s3Bucket = "INPUT YOUR S3 BUCKET NAME"
$zip = "S3 KEY ZIP FILE NAME"
$exe = "SERVICE EXE NAME"
$serviceName = "SERVICE NAME DEFINED IN TOPSHELF"
$destination = "C:\DOWNLOADPATH"
$downloadPath = Join-Path $destination $zip
$unzipPath = Join-Path $destination $serviceName
$servicePath = Join-Path $unzipPath "MSBUILD\EXTRACT\PATH\TO\$exe"
Import-DSCResource -ModuleName GraniResource
cS3Content SampleTopShelfContinuousDelivery
{
S3BucketName = $s3Bucket
Key = $zip
DestinationPath = $downloadPath
PreAction = {
if(Get-Service | where Name -eq $using:serviceName){ Stop-Service $using:serviceName }
if(Test-Path $using:unzipPath){ Remove-Item -Path $using:unzipPath -Recurse -Force }
}
}
Archive SampleTopShelfContinuousDelivery
{
Ensure = 'Present'
Path = $downloadPath
Destination = $unzipPath
}
cTopShelf SampleTopShelfContinuousDelivery
{
Ensure = "Present"
Path = $servicePath
ServiceName = $serviceName
DependsOn = "[Archive]InstallRapidHouse"
}
Service SampleTopShelfContinuousDelivery
{
Name = $serviceName
State = 'Running'
DependsOn = "[cTopShelf]InstallRapidHouse"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment