LucienShui / PasteMe

PasteMe 是一个无需注册的文本分享平台(未登陆状态下只能使用阅后即焚),可以为文本设置密码和阅后即焚,支持二维码分享和各种一键复制,针对代码提供了额外的高亮功能。
https://pasteme.cn
GNU General Public License v3.0
1.18k stars 153 forks source link

docker 启动失败 #125

Closed zhaojun1998 closed 2 years ago

zhaojun1998 commented 2 years ago

访问后有个 alter 弹窗,内容是 json 信息: {"message":"Request failed with status code 502","method":"get","url":"/api/v3/","params":{"method":"beat"}}

docker-compose.yml 为:

version: "3"

services:
  pasteme-frontend:
    image: pasteme/frontend:3.4.1
    container_name: pasteme-frontend
    depends_on:
      - pasteme-backend
    healthcheck:
      test: ["CMD", "curl", "-so", "/dev/null", "localhost:8080/usr/config.json"]
      interval: 45s
      timeout: 3s
      retries: 3
    restart: always
    ports:
      - 9081:8080
    volumes:
      - ./data/nginx-logs/:/var/lib/pasteme/
      - ./data/frontend-usr/:/www/pasteme/usr/

  pasteme-backend:
    image: pasteme/go-backend:3.5.1
    container_name: pasteme-backend
    depends_on:
      - pasteme-mysql
    healthcheck:
      test: ["CMD", "wget", "-O", "/dev/null", "localhost:8000/api/v3/?method=beat"]
      interval: 45s
      timeout: 3s
      retries: 3
    restart: always
    volumes:
      - ./data/backend-config/:/etc/pastemed/
    logging:
      driver: "json-file"
      options:
        max-file: "3"
        max-size: "128m"

  pasteme-mysql:
    image: mysql:5.5
    container_name: pasteme-mysql
    healthcheck:
      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
      interval: 45s
      timeout: 3s
      retries: 3
    restart: always
    command: [
      '--character-set-server=utf8mb4',
      '--collation-server=utf8mb4_unicode_ci'
    ]
    environment:
      MYSQL_USER: username
      MYSQL_PASSWORD: password
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: pasteme
      MYSQL_MAX_ALLOWED_PACKET: 128M
      MYSQL_INNODB_LOG_FILE_SIZE: 64M
    volumes:
      - ./data/mysql:/var/lib/mysql
    logging:
      driver: "json-file"
      options:
        max-file: "3"
        max-size: "128m"

仅修改了 pasteme-frontend 中端口 80 为 9081。

启动时,未加 -d,输出的日志信息为:

Starting pasteme-mysql ... done
Starting pasteme-backend ... done
Starting pasteme-frontend ... done
Attaching to pasteme-mysql, pasteme-backend, pasteme-frontend
pasteme-backend     | {"level":"panic","ts":1633761948.9060364,"caller":"config/config.go:49","msg":"invalid Config version","valid_config_version_list":["3.3.0",""],"config_version":"3.4.0","stacktrace":"github.com/PasteUs/PasteMeGoBackend/common/config.checkVersion\n\t/go/src/github.com/PasteUs/PasteMeGoBackend/common/config/config.go:49\ngithub.com/PasteUs/PasteMeGoBackend/common/config.init.0\n\t/go/src/github.com/PasteUs/PasteMeGoBackend/common/config/config.go:34\nruntime.doInit\n\t/usr/local/go/src/runtime/proc.go:6315\nruntime.doInit\n\t/usr/local/go/src/runtime/proc.go:6292\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:208"}
pasteme-backend     | panic: invalid Config version
pasteme-backend     | 
pasteme-backend     | goroutine 1 [running]:
pasteme-backend     | go.uber.org/zap/zapcore.(*CheckedEntry).Write(0xc0002cbd40, 0xc0002f6280, 0x2, 0x2)
pasteme-backend     |   /go/pkg/mod/go.uber.org/zap@v1.19.1/zapcore/entry.go:232 +0x532
pasteme-backend     | go.uber.org/zap.(*Logger).Panic(0xc0003436e0, 0xca8cf1, 0x16, 0xc0002f6280, 0x2, 0x2)
pasteme-backend     |   /go/pkg/mod/go.uber.org/zap@v1.19.1/logger.go:230 +0x85
pasteme-backend     | github.com/PasteUs/PasteMeGoBackend/common/logging.getLogger.func1(0xca8cf1, 0x16, 0xc00034b580, 0x2, 0x2)
pasteme-backend     |   /go/src/github.com/PasteUs/PasteMeGoBackend/common/logging/logger_func.go:38 +0x83
pasteme-backend     | github.com/PasteUs/PasteMeGoBackend/common/config.checkVersion(0xc0003b4468, 0x5)
pasteme-backend     |   /go/src/github.com/PasteUs/PasteMeGoBackend/common/config/config.go:49 +0x2ad
pasteme-backend     | github.com/PasteUs/PasteMeGoBackend/common/config.init.0()
pasteme-backend     |   /go/src/github.com/PasteUs/PasteMeGoBackend/common/config/config.go:34 +0x55
pasteme-frontend    | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
pasteme-frontend    | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
pasteme-frontend    | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
pasteme-frontend    | 10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf
pasteme-frontend    | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version
pasteme-frontend    | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
pasteme-mysql       | 211009  6:45:48 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
pasteme-mysql       | 211009  6:45:48 [Note] mysqld (mysqld 5.5.62) starting as process 1 ...
pasteme-mysql       | 211009  6:45:48 [Note] Plugin 'FEDERATED' is disabled.
pasteme-mysql       | 211009  6:45:48 InnoDB: The InnoDB memory heap is disabled
pasteme-mysql       | 211009  6:45:48 InnoDB: Mutexes and rw_locks use GCC atomic builtins
pasteme-mysql       | 211009  6:45:48 InnoDB: Compressed tables use zlib 1.2.11
pasteme-mysql       | 211009  6:45:48 InnoDB: Using Linux native AIO
pasteme-mysql       | 211009  6:45:48 InnoDB: Initializing buffer pool, size = 128.0M
pasteme-mysql       | 211009  6:45:48 InnoDB: Completed initialization of buffer pool
pasteme-mysql       | 211009  6:45:48 InnoDB: highest supported file format is Barracuda.
pasteme-mysql       | 211009  6:45:48  InnoDB: Waiting for the background threads to start
pasteme-frontend    | /docker-entrypoint.sh: Configuration complete; ready for start up
pasteme-backend exited with code 2
pasteme-mysql       | 211009  6:45:49 InnoDB: 5.5.62 started; log sequence number 1595675
pasteme-mysql       | 211009  6:45:49 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
pasteme-mysql       | 211009  6:45:49 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
pasteme-mysql       | 211009  6:45:49 [Note] Server socket created on IP: '0.0.0.0'.
pasteme-mysql       | 211009  6:45:49 [Warning] 'proxies_priv' entry '@ root@e68940af810d' ignored in --skip-name-resolve mode.
pasteme-mysql       | 211009  6:45:49 [Note] Event Scheduler: Loaded 0 events
pasteme-mysql       | 211009  6:45:49 [Note] mysqld: ready for connections.
pasteme-mysql       | Version: '5.5.62'  socket: '/tmp/mysql.sock'  port: 3306  MySQL Community Server (GPL)
pasteme-backend     | panic: invalid Config version
pasteme-backend     | 
pasteme-backend     | goroutine 1 [running]:
pasteme-backend     | go.uber.org/zap/zapcore.(*CheckedEntry).Write(0xc00029dd40, 0xc000300380, 0x2, 0x2)
pasteme-backend     |   /go/pkg/mod/go.uber.org/zap@v1.19.1/zapcore/entry.go:232 +0x532
pasteme-backend     | go.uber.org/zap.(*Logger).Panic(0xc000319860, 0xca8cf1, 0x16, 0xc000300380, 0x2, 0x2)
pasteme-backend     |   /go/pkg/mod/go.uber.org/zap@v1.19.1/logger.go:230 +0x85
pasteme-backend     | github.com/PasteUs/PasteMeGoBackend/common/logging.getLogger.func1(0xca8cf1, 0x16, 0xc000325640, 0x2, 0x2)
pasteme-backend     |   /go/src/github.com/PasteUs/PasteMeGoBackend/common/logging/logger_func.go:38 +0x83
pasteme-backend     | github.com/PasteUs/PasteMeGoBackend/common/config.checkVersion(0xc00037e508, 0x5)
pasteme-backend     |   /go/src/github.com/PasteUs/PasteMeGoBackend/common/config/config.go:49 +0x2ad
pasteme-backend     | github.com/PasteUs/PasteMeGoBackend/common/config.init.0()
pasteme-backend     |   /go/src/github.com/PasteUs/PasteMeGoBackend/common/config/config.go:34 +0x55
pasteme-backend     | panic: invalid Config version
pasteme-backend     | 
pasteme-backend     | goroutine 1 [running]:
pasteme-backend     | go.uber.org/zap/zapcore.(*CheckedEntry).Write(0xc0002d9d40, 0xc000354380, 0x2, 0x2)
pasteme-backend     |   /go/pkg/mod/go.uber.org/zap@v1.19.1/zapcore/entry.go:232 +0x532
pasteme-backend     | go.uber.org/zap.(*Logger).Panic(0xc00033b860, 0xca8cf1, 0x16, 0xc000354380, 0x2, 0x2)
pasteme-backend     |   /go/pkg/mod/go.uber.org/zap@v1.19.1/logger.go:230 +0x85
pasteme-backend     | github.com/PasteUs/PasteMeGoBackend/common/logging.getLogger.func1(0xca8cf1, 0x16, 0xc000351620, 0x2, 0x2)
pasteme-backend     |   /go/src/github.com/PasteUs/PasteMeGoBackend/common/logging/logger_func.go:38 +0x83
pasteme-backend     | github.com/PasteUs/PasteMeGoBackend/common/config.checkVersion(0xc0003ac4a8, 0x5)
pasteme-backend     |   /go/src/github.com/PasteUs/PasteMeGoBackend/common/config/config.go:49 +0x2ad
pasteme-backend     | github.com/PasteUs/PasteMeGoBackend/common/config.init.0()
pasteme-backend     |   /go/src/github.com/PasteUs/PasteMeGoBackend/common/config/config.go:34 +0x55
pasteme-backend exited with code 2
pasteme-backend exited with code 2
pasteme-backend exited with code 2
pasteme-backend     | panic: invalid Config version
pasteme-backend     | 
pasteme-backend     | goroutine 1 [running]:
pasteme-backend     | go.uber.org/zap/zapcore.(*CheckedEntry).Write(0xc00031dd40, 0xc00034a300, 0x2, 0x2)
pasteme-backend     |   /go/pkg/mod/go.uber.org/zap@v1.19.1/zapcore/entry.go:232 +0x532
pasteme-backend     | go.uber.org/zap.(*Logger).Panic(0xc0003958c0, 0xca8cf1, 0x16, 0xc00034a300, 0x2, 0x2)
pasteme-backend     |   /go/pkg/mod/go.uber.org/zap@v1.19.1/logger.go:230 +0x85
pasteme-backend     | github.com/PasteUs/PasteMeGoBackend/common/logging.getLogger.func1(0xca8cf1, 0x16, 0xc0003a35c0, 0x2, 0x2)
pasteme-backend     |   /go/src/github.com/PasteUs/PasteMeGoBackend/common/logging/logger_func.go:38 +0x83
pasteme-backend     | github.com/PasteUs/PasteMeGoBackend/common/config.checkVersion(0xc0003fe488, 0x5)
pasteme-backend     |   /go/src/github.com/PasteUs/PasteMeGoBackend/common/config/config.go:49 +0x2ad
pasteme-backend     | github.com/PasteUs/PasteMeGoBackend/common/config.init.0()
pasteme-backend     |   /go/src/github.com/PasteUs/PasteMeGoBackend/common/config/config.go:34 +0x55
pasteme-backend exited with code 2
pasteme-backend exited with code 2
pasteme-backend exited with code 2
pasteme-backend exited with code 2
pasteme-backend exited with code 2
pasteme-backend exited with code 2
pasteme-backend exited with code 2
pasteme-backend exited with code 2
pasteme-backend exited with code 2
pasteme-backend exited with code 2
LucienShui commented 2 years ago

可以看一下你的 config.json 吗?

zhaojun1998 commented 2 years ago

backend-config 下的配置文件:

{
  "version": "3.4.0",
  "address": "0.0.0.0",
  "port": 8000,
  "secret": "!!! CHANGE THIS !!!",
  "log_file": "pasteme.log",
  "database": {
    "type": "mysql",
    "username": "username",
    "password": "password",
    "server": "pasteme-mysql",
    "port": 3306,
    "database": "pasteme"
  }
}

frontend-usr 下的配置文件:

{
  "api": {
    "backend": "/api/v3/",
    "admin": ""
  },
  "footer": [
    {
      "url": "http://blog.lucien.ink/go/csdn",
      "text": "CSDN"
    },
    {
      "url": "https://github.com/LucienShui",
      "text": "GitHub"
    }
  ]
}
LucienShui commented 2 years ago

backend-config 里面,"version": "3.4.0" 改为 "version": "3.3.0" 试试。

zhaojun1998 commented 2 years ago

ok,可以了

LucienShui commented 2 years ago

好滴,有任何问题欢迎及时反馈哈。