0

我正在尝试在 gcp 云外壳上运行代码服务器。我下载了以下版本

https://github.com/cdr/code-server/releases/download/v3.9.2/code-server-3.9.2-linux-amd64.tar.gz我认为是正确的,提取了内容并跑了

code-server --auth none

这给出了以下输出

[2021-04-06T00:53:21.728Z] info  code-server 3.9.2 109d2ce3247869eaeab67aa7e5423503ec9eb859
[2021-04-06T00:53:21.730Z] info  Using user-data-dir ~/.local/share/code-server
[2021-04-06T00:53:21.751Z] info  Using config file ~/.config/code-server/config.yaml
[2021-04-06T00:53:21.751Z] info  HTTP server listening on http://127.0.0.1:8080
[2021-04-06T00:53:21.751Z] info    - Authentication is disabled
[2021-04-06T00:53:21.751Z] info    - Not serving HTTPS

现在,当我尝试Web Preview -> preview on port 8080什么都没发生时,我只是得到一个空白屏幕,在代码控制台上我看到以下错误

2021-04-06T00:50:04.470Z] 错误 vscode 握手超时 {"token":"e9b80ff7-10f9-4089-8497-b98688129452"}

我不确定我需要在这里做什么?

4

2 回答 2

1
  1. 在 cloud shell 编辑器中,创建一个扩展名为 .sh 的文件,并使用以下步骤安装代码服务器:

    export VERSION=`curl -s https://api.github.com/repos/cdr/code-server/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")'`
    
    wget https://github.com/cdr/code-server/releases/download/v3.10.2/code-server-3.10.2-linux-amd64.tar.gz
    
    tar -xvzf code-server-3.10.2-linux-amd64.tar.gz
    
    cd code-server-3.10.2-linux-amd64
    
  2. 使用终端运行 vscode.sh 文件: ./vscode.sh

    如果出现警告“权限被拒绝”,请键入chmod +x vscode.sh然后再次继续运行该文件。

  3. 要导航到文件夹: cd code-server-3.10.2-linux-amd64/

  4. 要导航到垃圾箱: cd bin/

  5. 启动服务器: ./code-server --auth none --port 8080

现在,您可以通过使用 web preview->preview on port 8080 选项或终端中的 HTTP 服务器链接在浏览器中查看 VSCode IDE。

于 2021-06-01T15:17:06.363 回答
0

My gut is saying that one must study this article (Expose code-server) in great detail. I think you will find that Code server is listening on IP address 127.0.0.1 at port 8080. Your thinking then is to access this server using Web Preview on port 8080 .... however ... pay attention to the IP addresses of your virtual machine. The IP address 127.0.0.1 is known as the loopback address. It is ONLY accessible to applications running on the SAME machine. My belief is that when you run Web Preview, you are trying to access the IP address of your Cloud Shell machine which is NOT 127.0.0.1.

If you read the above article, the story goes on to show how to use SSH forwarding to provide a front-end to whatever this application may be.

于 2021-04-06T03:00:10.403 回答