Fil*_*urt 3 msbuild powershell systemmanagement
对此系统管理问题的后续跟进:
由于我可能不会得到很多关于serverfault的反馈,我会在这里尝试一下.
我主要关心的是反映我必须管理的数据库,服务和任务/工作之间的依赖关系.
除了考虑Powershell之外,我甚至考虑过使用MSBuild,因为它允许建模依赖关系并重用配置目标.
换句话说: 我应该使用什么技术来开发灵活的解决方案,使我能够以正确的顺序停止机器D上的服务A,B和C,并在取下数据库X时禁用机器F上的任务E?
...当我取下数据库Y时,我想重新使用该部件来停止服务B和C.
如果您熟悉PowerShell并希望使用依赖项,请尝试使用psake.它看起来像什么:
psake script.ps1:-------
properties {
$dbServer = 'sqlexpress'
...
}
task default -depend StopServer1, StopServer2
task StopS1 -depend MakeS1Backup, StopSqlServer1 {
...
}
task MakeS1Backup {
... make backup
}
task StopSqlServer1 {
stop-service ...
}
# and anything similar to StopServer2
Run Code Online (Sandbox Code Playgroud)
然后你可以这样称呼它(还有更多的选择):
Invoke-Psake script.ps1
#or
Invoke-Psake script.ps1 -task StopS1 #calls only StopS1 task and all other scripts it depends on
#or
Invoke-Psake script.ps1 -task MakeS1Backup #only backups S1, it doesn't depend on anything else
Run Code Online (Sandbox Code Playgroud)
它做什么 - 它停止服务器1(任务StopS1),在此之前它处理StopS1依赖的所有任务.所以在停止S1的S1备份之前,Sql server 1停止等等.
我喜欢它比msbuild配置好得多,这是非常冗长和丑陋(虽然非常强大).
| 归档时间: |
|
| 查看次数: |
205 次 |
| 最近记录: |