简体   繁体   中英

How to start Redis within Ubuntu run via CircleCI

I have the following CircleCI config (this is trimmed, I don't include the config after the failing line):

version: 2
jobs:
  build:
    working_directory: ~/mycompany/mycompany_app
    docker:
    - image: ubuntu:18.04
    steps:
    - run:
        name: Update yum cache
        command: apt-get update
    - run:
        name: Install base packages
        command: apt-get install -y sudo git wget tzdata postgresql postgresql-contrib build-essential python2.7 make gcc redis-server
    - run:
        name: Start Redis
        command: sudo service redis-server start
    - run: redis-cli ping

The last command, redis-cli ping gives me the error Could not connect to Redis at 127.0.0.1:6379: Connection refused

The best thread I've been able to find on this issue is https://github.com/Microsoft/WSL/issues/365 though that doesn't help since I'm doing the manual start as they suggest. There's also some stuff in this SO answer that's related, but I don't think not using upstart is my problem.

How can I get the server started so that it will answer to the ping?

To really take advantage of CircleCI though, you might want to try doing it like this:

version: 2
jobs:
  build:
    working_directory: ~/mycompany/mycompany_app
    docker:
      - image: ubuntu:18.04
      - image: circleci/redis:4.0.9
    steps:
    - run:
        name: Update Apt Cache
        command: apt-get update
    - run:
        name: Install base packages
        command: apt-get install -y sudo git wget tzdata postgresql postgresql-contrib build-essential python2.7 make gcc
    - run: redis-cli ping

我通过将sudo service redis-server start更改为sudo redis-server --daemonize yes使其工作,这确实是链接的 Github 问题中列出的一个选项,尽管我认为它(就我的目的而言)与redis-server &所以我没试过。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM