crawlab-team / crawlab

Distributed web crawler admin platform for spiders management regardless of languages and frameworks. 分布式爬虫管理平台,支持任何语言和框架
https://www.crawlab.cn
BSD 3-Clause "New" or "Revised" License
11.34k stars 1.78k forks source link

admin 通过vscode port登陆失败 #1116

Closed kevinzhangcode closed 2 years ago

kevinzhangcode commented 2 years ago

Bug 描述 我将机器部署在内网服务器,通过vscodeport功能映射到本机打开,例如,当输入用户名和密码均为admin 时,登陆功能不工作。 vscode port配置

image

登陆错误

image

排除其他因素 远程主机端口6800存在scrapyd的管理界面,vscode能将远程主机的6800映射到本机端口上。

image

期望结果 登陆admin 能工作。

tikazyq commented 2 years ago

可能需要端口配置,最好提供一些更详细的信息

tikazyq commented 2 years ago

可能需要端口配置,最好提供一些更详细的信息

kevinzhangcode commented 2 years ago

@tikazyq 这是我的配置文件 docker-compose.yml

version: '3.3'
services:
  master:
    image: crawlabteam/crawlab
    container_name: crawlab_master
    restart: always
    environment:
      CRAWLAB_NODE_MASTER: Y  # Y: 主节点
      CRAWLAB_MONGO_HOST: mongo  # mongo host address. 在 Docker-Compose 网络中,直接引用 service 名称
      CRAWLAB_MONGO_PORT: 7990  # mongo port 
      CRAWLAB_MONGO_DB: crawlab  # mongo database 
      CRAWLAB_MONGO_USERNAME: admin  # mongo username
      CRAWLAB_MONGO_PASSWORD: 123456  # mongo password 
      CRAWLAB_MONGO_AUTHSOURCE: admin  # mongo auth source 
    volumes:
      - "/home/xxxx/mycrawlab/master:/data"  # 持久化 crawlab 数据
    ports:
      - "7991:8080"  # 开放 api 端口
    depends_on:
      - mongo

  mongo:
    image: mongo:4.2
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: admin  # mongo username
      MONGO_INITDB_ROOT_PASSWORD: 123456  # mongo password
    volumes:
      - "/home/xxxx/mycrawlab/data/db:/data/db"  # 持久化 mongo 数据
    ports:
      - "7990:27017"  # 开放 mongo 端口到宿主机

docker容器检查

image
tikazyq commented 2 years ago

你是在docker里安装了scrapyd么?

kevinzhangcode commented 2 years ago

@tikazyq 没有,scrapyd是指我的conda虚拟环境中安装的,为了守护这个进程,我把scrapyd放入screen,我在思考🤔是不是需要修改crawlab_master docker容器中的配置,非常感谢您的协助🙏🏻。

tikazyq commented 2 years ago

不是很理解你希望实现的是什么...

kevinzhangcode commented 2 years ago

展示scrapyd能正常连接的目的是:验证其他应用的端口能正常被vscode转发, 问题:在没有配置其他管理,界面初始化无法使用默认账户/密码:admin/admin 登陆。

tikazyq commented 2 years ago

看看docker日志是否有问题

docker logs crawlab_master

kevinzhangcode commented 2 years ago

@tikazyq 日志

server selection error: server selection timeout, current topology: { Type: Unknown, Servers: [{ Addr: mongo:7990, Type: Unknown, Last error: connection() error occured during connection handshake: dial tcp 172.19.0.2:7990: connect: connection refused }, ] }
/go/pkg/mod/github.com/crawlab-team/go-trace@v0.1.1/trace.go:13 github.com/crawlab-team/go-trace.TraceError()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/user/service.go:224 github.com/crawlab-team/crawlab-core/user.NewUserService()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/user/service.go:242 github.com/crawlab-team/crawlab-core/user.GetUserService()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/user/service.go:252 github.com/crawlab-team/crawlab-core/user.ProvideGetUserService.func1()
/usr/local/go/src/reflect/value.go:476 reflect.Value.call()
/usr/local/go/src/reflect/value.go:337 reflect.Value.Call()
/go/pkg/mod/go.uber.org/dig@v1.10.0/dig.go:284 go.uber.org/dig.defaultInvoker()
/go/pkg/mod/go.uber.org/dig@v1.10.0/dig.go:710 go.uber.org/dig.(*node).Call()
/go/pkg/mod/go.uber.org/dig@v1.10.0/param.go:245 go.uber.org/dig.paramSingle.Build()
/go/pkg/mod/go.uber.org/dig@v1.10.0/param.go:201 go.uber.org/dig.paramList.BuildList()
/go/pkg/mod/go.uber.org/dig@v1.10.0/dig.go:432 go.uber.org/dig.(*Container).Invoke()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/controllers/user.go:224 github.com/crawlab-team/crawlab-core/controllers.newUserContext()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/controllers/user.go:25 github.com/crawlab-team/crawlab-core/controllers.getUserActions()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/controllers/user.go:243 github.com/crawlab-team/crawlab-core/controllers.newUserController()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/controllers/init.go:18 github.com/crawlab-team/crawlab-core/controllers.InitControllers()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/apps/utils.go:26 github.com/crawlab-team/crawlab-core/apps.initModule()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/apps/api.go:28 github.com/crawlab-team/crawlab-core/apps.(*Api).Init()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/apps/api.go:85 github.com/crawlab-team/crawlab-core/apps.NewApi()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/apps/api.go:95 github.com/crawlab-team/crawlab-core/apps.GetApi()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/apps/master.go:68 github.com/crawlab-team/crawlab-core/apps.NewMaster()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/apps/master.go:103 github.com/crawlab-team/crawlab-core/apps.GetMaster()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/cmd/master.go:23 github.com/crawlab-team/crawlab-core/cmd.glob..func1()
/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:860 github.com/spf13/cobra.(*Command).execute()
/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:974 github.com/spf13/cobra.(*Command).ExecuteC()
/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:902 github.com/spf13/cobra.(*Command).Execute()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/cmd/root.go:23 github.com/crawlab-team/crawlab-core/cmd.Execute()
/go/src/app/main.go:8 main.main()
/usr/local/go/src/runtime/proc.go:225 runtime.main()
/usr/local/go/src/runtime/asm_amd64.s:1371 runtime.goexit()
panic: could not build arguments for function "github.com/crawlab-team/crawlab-core/controllers".newUserContext.func1 (/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/controllers/user.go:224): failed to build interfaces.UserService: received non-nil error from function "github.com/crawlab-team/crawlab-core/user".ProvideGetUserService.func1 (/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/user/service.go:251): server selection error: server selection timeout, current topology: { Type: Unknown, Servers: [{ Addr: mongo:7990, Type: Unknown, Last error: connection() error occured during connection handshake: dial tcp 172.19.0.2:7990: connect: connection refused }, ] }

goroutine 1 [running]:
github.com/crawlab-team/crawlab-core/controllers.newUserContext(0xefac6b)
        /go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/controllers/user.go:231 +0x1d7
github.com/crawlab-team/crawlab-core/controllers.getUserActions(0xc0007d84c0, 0x8, 0x14be848)
        /go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/controllers/user.go:25 +0x26
github.com/crawlab-team/crawlab-core/controllers.newUserController(0xc0001b4a50)
        /go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/controllers/user.go:243 +0x9c
github.com/crawlab-team/crawlab-core/controllers.InitControllers(0x30, 0x7f0fd0598a68)
        /go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/controllers/init.go:18 +0xe5
github.com/crawlab-team/crawlab-core/apps.initModule(0x1273a19, 0xb, 0x12d4f68, 0x11b17a0, 0xc000524301)
        /go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/apps/utils.go:26 +0x3c
github.com/crawlab-team/crawlab-core/apps.(*Api).Init(0xc000389980)
        /go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/apps/api.go:28 +0x46
github.com/crawlab-team/crawlab-core/apps.NewApi(0x149f9c0)
        /go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/apps/api.go:85 +0x65
github.com/crawlab-team/crawlab-core/apps.GetApi(...)
        /go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/apps/api.go:95
github.com/crawlab-team/crawlab-core/apps.NewMaster(0x0, 0x0, 0x0, 0x0, 0x0)
        /go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/apps/master.go:68 +0x385
github.com/crawlab-team/crawlab-core/apps.GetMaster(...)
        /go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/apps/master.go:103
github.com/crawlab-team/crawlab-core/cmd.glob..func1(0x1b80b60, 0x1bc0e98, 0x0, 0x0)
        /go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/cmd/master.go:23 +0x85
github.com/spf13/cobra.(*Command).execute(0x1b80b60, 0x1bc0e98, 0x0, 0x0, 0x1b80b60, 0x1bc0e98)
        /go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:860 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x1b80de0, 0x0, 0xffffffff, 0xc000180058)
        /go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:974 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        /go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:902
github.com/crawlab-team/crawlab-core/cmd.Execute(...)
        /go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0/cmd/root.go:23
main.main()
        /go/src/app/main.go:8 +0x2e
 * Starting nginx nginx
   ...done.
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)
tikazyq commented 2 years ago

CRAWLAB_MONGO_PORT: 7990

这个改为 CRAWLAB_MONGO_PORT: 27017

kevinzhangcode commented 2 years ago

非常感谢您的协助🙏🏻,问题已经成功解决。