forked from chucknorris/dropkick
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request chucknorris#1 from davidduffett/master
NServiceBus.Host deployment
- Loading branch information
Showing
6 changed files
with
306 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
product/dropkick/Configuration/Dsl/NServiceBusHost/Extension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2007-2010 The Apache Software Foundation. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
namespace dropkick.Configuration.Dsl.NServiceBusHost | ||
{ | ||
using System; | ||
using FileSystem; | ||
|
||
public static class Extension | ||
{ | ||
public static void NServiceBusHost(this ProtoServer server, Action<NServiceBusHostOptions> action) | ||
{ | ||
var cfg = new NServiceBusHostConfigurator(new DotNetPath()); | ||
action(cfg); | ||
server.RegisterProtoTask(cfg); | ||
} | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
product/dropkick/Configuration/Dsl/NServiceBusHost/NServiceBusHostConfigurator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright 2007-2010 The Apache Software Foundation. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
namespace dropkick.Configuration.Dsl.NServiceBusHost | ||
{ | ||
using DeploymentModel; | ||
using FileSystem; | ||
using Tasks; | ||
using Tasks.NServiceBusHost; | ||
|
||
public class NServiceBusHostConfigurator : | ||
BaseProtoTask, | ||
NServiceBusHostOptions | ||
{ | ||
readonly Path _path; | ||
string _serviceName; | ||
string _displayName; | ||
string _description; | ||
string _instanceName; | ||
string _location; | ||
string _exeName; | ||
string _password; | ||
string _username; | ||
|
||
public NServiceBusHostConfigurator(Path path) | ||
{ | ||
_path = path; | ||
} | ||
|
||
public void ExeName(string name) | ||
{ | ||
_exeName = name; | ||
} | ||
|
||
public void Instance(string name) | ||
{ | ||
_instanceName = name; | ||
} | ||
|
||
public void LocatedAt(string location) | ||
{ | ||
_location = location; | ||
} | ||
|
||
public void PassCredentials(string username, string password) | ||
{ | ||
_username = username; | ||
_password = password; | ||
} | ||
|
||
public void ServiceName(string name) | ||
{ | ||
_serviceName = name; | ||
} | ||
|
||
public void ServiceDisplayName(string name) | ||
{ | ||
_displayName = name; | ||
} | ||
|
||
public void ServiceDescription(string description) | ||
{ | ||
_description = description; | ||
} | ||
|
||
public override void RegisterRealTasks(PhysicalServer site) | ||
{ | ||
var location = _path.GetPhysicalPath(site, _location, true); | ||
if (site.IsLocal) | ||
{ | ||
site.AddTask(new LocalNServiceBusHostTask(_exeName, location, _instanceName, _username, _password, _serviceName, _displayName, _description)); | ||
} | ||
else | ||
{ | ||
site.AddTask(new RemoteNServiceBusHostTask(_exeName, location, _instanceName, site, _username, _password, _serviceName, _displayName, _description)); | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
product/dropkick/Configuration/Dsl/NServiceBusHost/NServiceBusHostOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2007-2010 The Apache Software Foundation. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
namespace dropkick.Configuration.Dsl.NServiceBusHost | ||
{ | ||
public interface NServiceBusHostOptions | ||
{ | ||
void ExeName(string name); | ||
void Instance(string name); | ||
void LocatedAt(string location); | ||
void PassCredentials(string username, string password); | ||
void ServiceName(string name); | ||
void ServiceDisplayName(string name); | ||
void ServiceDescription(string description); | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
product/dropkick/Tasks/NServiceBusHost/LocalNServiceBusHostTask.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright 2007-2010 The Apache Software Foundation. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
namespace dropkick.Tasks.NServiceBusHost | ||
{ | ||
using CommandLine; | ||
using DeploymentModel; | ||
using FileSystem; | ||
using Prompting; | ||
|
||
public class LocalNServiceBusHostTask : | ||
BaseTask | ||
{ | ||
private readonly LocalCommandLineTask _task; | ||
private readonly PromptService _prompt = new ConsolePromptService(); | ||
|
||
public LocalNServiceBusHostTask(string exeName, string location, string instanceName, string username, string password, string serviceName, string displayName, string description) | ||
{ | ||
string args = string.IsNullOrEmpty(instanceName) | ||
? "" | ||
: " /instance:" + instanceName; | ||
|
||
if (username != null && password != null) | ||
{ | ||
var user = username; | ||
var pass = password; | ||
if (username.ShouldPrompt()) | ||
user = _prompt.Prompt("Win Service '{0}' UserName".FormatWith(exeName)); | ||
if (shouldPromptForPassword(username, password)) | ||
pass = _prompt.Prompt("Win Service '{0}' For User '{1}' Password".FormatWith(exeName, username)); | ||
|
||
args += " /username:{0}".FormatWith(user); | ||
if (!string.IsNullOrEmpty(pass)) | ||
args += " /password:{0}".FormatWith(pass); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(serviceName)) | ||
args += " /serviceName:\"{0}\"".FormatWith(serviceName); | ||
|
||
if (!string.IsNullOrEmpty(displayName)) | ||
args += " /displayName:\"{0}\"".FormatWith(displayName); | ||
|
||
if (!string.IsNullOrEmpty(description)) | ||
args += " /description:\"{0}\"".FormatWith(description); | ||
|
||
_task = new LocalCommandLineTask(new DotNetPath(), exeName) | ||
{ | ||
Args = "/install " + args, | ||
ExecutableIsLocatedAt = location, | ||
WorkingDirectory = location | ||
}; | ||
} | ||
|
||
public override string Name | ||
{ | ||
get { return "[nservicebushost] local Installing"; } | ||
} | ||
|
||
public override DeploymentResult VerifyCanRun() | ||
{ | ||
return _task.VerifyCanRun(); | ||
} | ||
|
||
public override DeploymentResult Execute() | ||
{ | ||
Logging.Coarse("[nservicebushost] Installing a local NServiceBus.Host service."); | ||
return _task.Execute(); | ||
} | ||
|
||
private bool shouldPromptForPassword(string username, string password) | ||
{ | ||
return !WindowsAuthentication.IsBuiltInUsername(username) && password.ShouldPrompt(); | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
product/dropkick/Tasks/NServiceBusHost/RemoteNServiceBusHostTask.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright 2007-2010 The Apache Software Foundation. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
// this file except in compliance with the License. You may obtain a copy of the | ||
// License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
namespace dropkick.Tasks.NServiceBusHost | ||
{ | ||
using CommandLine; | ||
using DeploymentModel; | ||
using Prompting; | ||
|
||
public class RemoteNServiceBusHostTask : | ||
BaseTask | ||
{ | ||
readonly RemoteCommandLineTask _task; | ||
readonly PromptService _prompt = new ConsolePromptService(); | ||
|
||
public RemoteNServiceBusHostTask(string exeName, string location, string instanceName, PhysicalServer site, string username, string password, string serviceName, string displayName, string description) | ||
{ | ||
string args = string.IsNullOrEmpty(instanceName) | ||
? "" | ||
: " /instance:" + instanceName; | ||
|
||
if (username != null && password != null) | ||
{ | ||
var user = username; | ||
var pass = password; | ||
if (username.ShouldPrompt()) | ||
user = _prompt.Prompt("Win Service '{0}' UserName".FormatWith(exeName)); | ||
if (password.ShouldPrompt()) | ||
pass = _prompt.Prompt("Win Service '{0}' For User '{1}' Password".FormatWith(exeName, username)); | ||
|
||
args += " /username:{0} /password:{1}".FormatWith(user, pass); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(serviceName)) | ||
args += " /serviceName:\"{0}\"".FormatWith(serviceName); | ||
|
||
if (!string.IsNullOrEmpty(displayName)) | ||
args += " /displayName:\"{0}\"".FormatWith(displayName); | ||
|
||
if (!string.IsNullOrEmpty(description)) | ||
args += " /description:\"{0}\"".FormatWith(description); | ||
|
||
_task = new RemoteCommandLineTask(exeName) | ||
{ | ||
Args = "/install" + args, | ||
ExecutableIsLocatedAt = location, | ||
Machine = site.Name, | ||
WorkingDirectory = location | ||
}; | ||
} | ||
|
||
public override string Name | ||
{ | ||
get { return "[nservicebushost] remote Installing"; } | ||
} | ||
|
||
public override DeploymentResult VerifyCanRun() | ||
{ | ||
return _task.VerifyCanRun(); | ||
} | ||
|
||
public override DeploymentResult Execute() | ||
{ | ||
Logging.Coarse("[nservicebushost] Installing a remote NServiceBus.Host service"); | ||
return _task.Execute(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters