1…error: version in “./docker-compose.yml” is unsupported. you might be seeing this error because you’re using the wrong compose file version. either specify a supported version
我看了下我的docker是20以上的,这个version:3.7 应该能够编译,后面发现挂钩的是 docker-compose(版本)1.17 .要不降version,要不升级compose
docker-compose 版本不匹配,使用下面代码安装新的
2…docker-compose 下载慢,用这个
curl -L https://get.daocloud.io/docker/compose/releases/download/1.29.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
version: '3.7'
services:
postgres:
image: postgres:11
env_file: .env
volumes:
- ./data/postgres-data:/var/lib/postgresql/data
ports:
- "5432:5432"
redis:
image: redis:5.0.7
ports:
- "6379:6379"
3…An error occurred while installing pg (1.2.3), and Bundler cannot continue.
可能没安装 “ sudo apt-get install libpq-dev“”
4…LoadError: cannot load such file – rexml/document
rexml 不再内置,需要自己添加 gemfile 添加:gem ‘rexml’
5…https://mrzou.github.io/ruby-sidekiq(sidekiq)
使用sidekiq 需要 内置数据库 redis
6…pg,redis需要注意的几个文件
配置文件:
- sidekiq.rb
- docker-compose.yml
- .env
- .env.development.local
- datebase.yml
7…在启动pg,redis中出现错误:
could not translate host name “postgres” to address: Name or service not known
在不确定具体原因的情况下:
datebase.yml 中所有的 “配置名称”全部手写;
要于.env中的username,password 要一样 host :127.0.0.1
default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 20 } %>
timeout: 30000
encoding: unicode
# username: <%= ENV['POSTGRES_USER'] %>
# password: <%= ENV['POSTGRES_PASSWORD'] %>
# host: <%= ENV['POSTGRES_HOST'] %>
# port: <%= ENV['POSTGRES_PORT'] %>
username: postgres
password: postgres
host: 127.0.0.1
port: 5432
development:
<<: *default
database: wreeto_dev
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: wreeto_test
production:
<<: *default
database: wreeto_db
8…Redis::CannotConnectError: Error connecting to Redis on redis:6379 (SocketError)
改成下面这样:
require 'sidekiq'
require 'sidekiq-status'
Sidekiq.configure_client do |config|
config.redis = { url: (ENV["REDIS_URL"] || 'redis://127.0.0.1:6379/0') }
# accepts :expiration (optional)
Sidekiq::Status.configure_client_middleware config, expiration: 30.minutes
end
Sidekiq.configure_server do |config|
config.redis = { url: (ENV["REDIS_URL"] || 'redis://127.0.0.1:6379/0') }
# accepts :expiration (optional)
Sidekiq::Status.configure_server_middleware config, expiration: 30.minutes
# accepts :expiration (optional)
Sidekiq::Status.configure_client_middleware config, expiration: 30.minutes
end