【问题标题】:Is there a way to run HashiCorp Vault as a Windows Service?有没有办法将 HashiCorp Vault 作为 Windows 服务运行?
【发布时间】:2017-03-22 06:20:21
【问题描述】:

我目前在我的机器上设置了保管库服务器。但是,我希望它在我的机器重新启动后自动启动。本质上,我希望它自动运行 Vault 服务器启动脚本,例如:

     vault server -config C:\vault_0.6.2\config.hcl

并使用 3 把钥匙打开保险库。 我以前使用 Windows Service Wrapper (winsv) 将 Spring Boot 应用程序安装为 Windows 服务。是否可以使用 winsv 来运行 vault?或者,如果可以使用 winsv 执行 2 个 bat 文件(一个包含保管库服务器,另一个用于保管库解封)? 我使用的是 Windows 10。
感谢您的帮助,谢谢!

【问题讨论】:

    标签: batch-file service windows-services wrapper hashicorp-vault


    【解决方案1】:

    以防将来有人尝试这样做。解决方案是让服务启动保管库服务器。该服务使用 ProcessBuilder 运行包含以下内容的 bat 脚本:

    启动 /b 保管库服务器 -config "C:\vault_0.6.2\config.hcl"

    然后它使用另一个 ProcessBuilder 运行第二个 bat 脚本,其中包含: 保险库开封 %1

    ,其中 %1 是服务传递的参数。

    【讨论】:

    • 非常感谢分享这个过程。但是当私钥可用时如何处理。因为在这种情况下,它会在提示“输入私钥的密码”时暂停。请您提供一些相关信息。
    【解决方案2】:

    除了服务之外,您还可以使用系统帐户创建在启动时运行的计划任务。

    #Start Vault with scheduledtask (powershell)     
    $action  = New-ScheduledTaskAction -Execute "$vaultpath\vault.exe" -Argument "server -config=`"$vaultpath\config.hcl`"" 
    
    $trigger = New-ScheduledTaskTrigger -AtStartup  
    
    try{
    
        $createTask = Register-ScheduledTask -Action $action -Trigger $trigger -TaskName   "Hashicorp_Vault" -Description "Run Hashicorp Vault" -User system -ErrorAction stop
    
        if($createTask){
            remove-variabel -name createTask
        }
    
    }Catch{
    
        write-host "[Vault] : The Vault task already exists" -for green
    
    }
    

    https://d2c-it.nl/2019/03/27/hashicorp-vault-on-windows-with-powershell/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-29
      • 2022-10-22
      • 2014-12-01
      • 2010-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多