在Windows上安装SourceGraph记录

Fri 01 March 2019 / In categories Tools

SourceGraph

Sourcegraph是一款代码浏览器工具,同时支持Language Server Protocol,可以用来为IDE做补全。本文记录在Windows上安装Sourcegraph 3.1.1。

首先需要在Windows上安装Docker。到Docker的网站下载Docker Desktop版本安装即可。

然后,在用户目录%userprofile%下创建目录.sourcegraph/data.sourcegraph/config。如果不执行这一步,会产生错误:Sourcegraph Server docker run doesn’t work on Windows if ~/.sourcegraph does not exist

接着根据Sourcegraph documentation,执行下面命令安装Sourcegraph 3.1.1:

docker run --publish 7080:7080 --publish 2633:2633 --rm --volume ~/.sourcegraph/config:/etc/sourcegraph --volume ~/.sourcegraph/data:/var/opt/sourcegraph sourcegraph/server:3.1.1

如果出现下面的错误:

running bootstrap script ... 2019-02-25 03:40:13.682 UTC [41] FATAL:  data directory "/var/opt/sourcegraph/postgresql" has wrong ownership
2019-02-25 03:40:13.682 UTC [41] HINT:  The server must be started by the user that owns the data directory.
child process exited with exit code 1
initdb: removing contents of data directory "/var/opt/sourcegraph/postgresql"

根据这个Github Issue的解释,需要:

docker volume create --name sourcegraph-data-volume -d local

然后使用下面的参数重新执行docker run

docker run --publish 7080:7080 --publish 2633:2633 --rm --volume ~/.sourcegraph/config:/et
c/sourcegraph --volume sourcegraph-data-volume:/var/opt/sourcegraph sourcegraph/server:3.1.1

如果出现了下面错误:

[Mounting data volume for Postgres in docker for Windows doesn't work #445](https://github.com/docker/for-win/issues/445)

03:46:58           postgres | 2019-02-25 03:46:58.250 UTC [48] LOG:  listening on IPv4 address "127.0.0.1", port 5432
03:46:58     syntect_server | Configured for production.
03:46:58              redis | 116:C 25 Feb 03:46:58.303 # Can't chdir to '/var/opt/sourcegraph/redis': No such file or directory
03:46:58              redis | Terminating redis

根据这条Github Issue,把.sourcegraph\config中的内容清空后重试便可。

其他

Load Disqus Comments