2

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?

Matthew Herbst
  • 29,477
  • 23
  • 85
  • 128

2 Answers2

1

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
FelicianoTech
  • 3,894
  • 2
  • 13
  • 18
  • Does seem to work :( `====>> redis-cli ping #!/bin/bash -eo pipefail redis-cli ping /bin/bash: redis-cli: command not found Error: Exited with code 127 Step failed Error: runner failed Task failed` – Matthew Herbst Sep 04 '18 at 18:42
  • I had the same issues trying to get postgres running in a side image - ended up installing that manually as well – Matthew Herbst Sep 04 '18 at 18:43
  • Depending on what your build is doing, you might be accessing the DB too fast. The `dockerize` command is available to wait for the DB port to be available before trying to use it. – FelicianoTech Sep 05 '18 at 17:06
  • 1
    Seems simpler to just create my own custom container with the dbs already installed and then just go from there. Thanks for the info on `dockerize` though! – Matthew Herbst Sep 05 '18 at 19:29
0

I got it working by changing sudo service redis-server start to sudo redis-server --daemonize yes which was indeed an option listed in the linked Github issue, though I had thought it was equivalent (for my purposes) to redis-server & so I hadn't tried it.

Matthew Herbst
  • 29,477
  • 23
  • 85
  • 128