[英]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):我有以下 CircleCI 配置(这是修剪过的,我不包括失败行后的配置):
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
最后一个命令,
redis-cli ping
给了我错误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.我能在这个问题上找到的最好的线程是https://github.com/Microsoft/WSL/issues/365虽然这没有帮助,因为我正在按照他们的建议进行手动启动。 There's also some stuff in this SO answer that's related, but I don't think not using
upstart
is my problem.在这个 SO 答案中也有一些相关的东西,但我不认为不使用
upstart
是我的问题。
How can I get the server started so that it will answer to the ping?如何启动服务器以便它响应 ping?
To really take advantage of CircleCI though, you might want to try doing it like this:不过,要真正利用 CircleCI,您可能想尝试这样做:
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 &
所以我没试过。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.