【问题标题】:start redis-server on appveyor在 appveyor 上启动 redis-server
【发布时间】:2015-02-23 12:24:03
【问题描述】:

我想在需要可用的 redis 实例的 AppVeyor 上运行一些 xUnit 测试。 我没有在 AppVeyor 的“服务”中找到 Redis,所以我最终得到了一个自定义解决方案,正如您从 appveyor.yml 中看到的那样

version: 1.0.{build}
before_build:
- nuget restore .\Hangfire.Redis.StackExchange.sln
- START .\packages\Redis-32.2.6.12.1\tools\redis-server.exe ".\packages\Redis-32.2.6.12.1\tools\redis.conf"
- '@ECHO Redis Started'
build:
  publish_nuget: true
  publish_nuget_symbols: true
  verbosity: minimal

不幸的是,构建过程停留在START .\packages\Redis-32.2.6.12.1\tools\redis-server.exe ".\packages\Redis-32.2.6.12.1\tools\redis.conf"

有什么想法或可能的解决方法吗?

【问题讨论】:

    标签: redis appveyor


    【解决方案1】:

    尝试将 Redis 作为 Windows 服务运行:

    before_build:
    - nuget restore .\Hangfire.Redis.StackExchange.sln
    - packages\Redis-32.2.6.12.1\tools\redis-server.exe --service-install
    - packages\Redis-32.2.6.12.1\tools\redis-server.exe --service-start
    - '@ECHO Redis Started'
    

    【讨论】:

    • 好主意!不幸的是2.6.12版本的redis不支持作为服务安装,但是我会通过chocolatey尝试同样的想法
    • 成功了! ;) 我将在这里发布答案
    • 太棒了!供将来参考 - 在不阻止构建的情况下启动进程的另一种方法是使用 Start-Process PowerShell cmdlet。通常,您应该使用Start-Sleep cmdlet 在下一行添加一些延迟以允许进程启动。
    【解决方案2】:

    就我个人而言,我总是使用 Chocolatey 在 AppVeyor Build Worker 上安装所需的任何基础设施。所以这是我将使用的 appveyor.yml(它适用于我自己的需要 Redis 的项目):

    version: 1.0.{build}
    before_build:
    - choco install redis-64
    - redis-server --service-install
    - redis-server --service-start
    - nuget restore .\Hangfire.Redis.StackExchange.sln
    build:
      publish_nuget: true
      publish_nuget_symbols: true
      verbosity: minimal
    

    【讨论】:

      【解决方案3】:

      对于任何感兴趣的人来说,这就是 appveyor.yml 的诀窍。 它基本上是直接从 github 下载版本,解压到一个文件夹中,安装并启动 Redis 作为服务

      version: 1.0.{build}
      before_build:
      - ps: >-
          Invoke-WebRequest "https://github.com/MSOpenTech/redis/releases/download/win-2.8.17.4/redis-2.8.17.zip" -OutFile .\redis-2.8.17.zip;
      
          $destFolder = "redis-2.8.17";
      
          $shell = new-object -com shell.application;
      
      
          $zip = $shell.NameSpace("$pwd\redis-2.8.17.zip");
      
          if (Test-Path $pwd\$destFolder )
      
          {
              del $pwd\$destFolder -Force -Recurse
          }
      
          md ".\redis-2.8.17";
      
          foreach($item in $zip.items())
      
          {
              $shell.Namespace("$pwd\redis-2.8.17").copyhere($item);
          it kind of worked
      
          cd $destFolder
      
          .\redis-server.exe --service-install
      
          .\redis-server.exe --service-start
      
          cd ..
      - nuget restore Hangfire.Redis.StackExchange.sln
      build:
        publish_nuget: true
        publish_nuget_symbols: true
        verbosity: minimal
      

      【讨论】:

        【解决方案4】:

        这里是 appveyor.yml 的示例,它带有一个适用于 redis-3.2.100 的 powershell 脚本,目前在巧克力上不可用:

        appveyor.yml

        install:
            - cmd: cd c:\ && mkdir c:\redis-3.2.100
            - ps: c:\Users\root\repos\<YOUR_REPO>\deploy\redis.ps1
        

        redis.ps1

        Add-Type -assembly "system.io.compression.filesystem"
        $source="https://github.com/MicrosoftArchive/redis/releases/download/win-3.2.100/Redis-x64-3.2.100.zip"
        $destination="c:\redisarchive"
        Invoke-WebRequest $source -OutFile $destination
        [IO.Compression.ZipFile]::ExtractToDirectory('c:\redisarchive', 'c:\redis-3.2.100')
        
        cd c:\redis-3.2.100
        .\redis-server.exe --service-install
        .\redis-server.exe --service-start
        cd ..
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2021-11-06
          • 2012-08-05
          • 2014-03-20
          • 2021-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-12-05
          • 2018-04-07
          相关资源
          最近更新 更多