Long pause in standard installation of command : cd /var/www/discourse && su discourse -c 'bundle install --retry 3 --jobs 4'

hello guys! i am a new user of discourse from china ,and i meet a strange issue in standard installation

after execute the command ./discourse-setup, my terminal stuttered on command for a long time ( more than 20 minutes)

I, [2023-06-04T07:47:29.161469 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle config --local deployment true'
I, [2023-06-04T07:47:29.544117 #1]  INFO -- : 
I, [2023-06-04T07:47:29.544260 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle config --local without "development test"'
I, [2023-06-04T07:47:29.725190 #1]  INFO -- : You are replacing the current local value of without, which is currently "test:development"
I, [2023-06-04T07:47:29.725290 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle install --retry 3 --jobs 4'

i have searched similar questions in out forum, like Local installation of discourse on Centos 7 which prompted it may be a network problem. Maybe just because my server is in China , and i meet network problem but i have test via wget https://rubygems.org/, it worked

i don’t know how to do , thanks for your reply

well, it is indeed a network problem , because my server is in China
I finde the resolutions, copy here in chinese


在国内环境下安装Discoursehttps://mypre.cn/2021/02/17/Discourcs-setup-on-cvm-ecs/

Discourse的版本升级与维护都是基于github来完成的,而Discourse本身又是基于ruby编写。

使用包括腾讯云的CVM、轻量服务器以及阿里云的ECS都存在国外网站访问慢的问题,主要是为了扶持国内git仓库做的限流操作。

在clone托管在github上的discourse时,可以通过将clone链接替换github.com为github.com.cnpmjs.org来加速对github的访问,比如:

git clone https://github.com/discourse/discourse_docker.git 替换为 git clone https://github.com.cnpmjs.org/discourse/discourse_docker.git

除此之外,在运行./discourse-setup时,安装程序同样会在docker中安装一些额外的的项目,

比如:gem update,同样需要添加ruby的镜像。

可以通过修改配置文件来添加ruby镜像地址,主要涉及到的文件有 docker.git

除此之外,在运行./discourse-setup时,安装程序同样会在docker中安装一些额外的的项目,

比如:gem update,同样需要添加ruby的镜像。

可以通过修改配置文件来添加ruby镜像地址,主要涉及到的文件有

discourse/templates/web.template.yml
discourse/containers/app.yml

查找上述文件中调用gem update的地方之前添加如下配置镜像站点的语句:

gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
gem update bundler

对于bundle可以使用bundle config mirror.https://rubygems.org https://gems.ruby-china.com来添加镜像网站。

主要修改如下:

diff --git a/templates/web.template.yml b/templates/web.template.yml
index 28fb22d..bb0010c 100644
--- a/templates/web.template.yml
+++ b/templates/web.template.yml
@@ -86,6 +86,9 @@ run:
       cd: $home
       hook: code
       cmd:
+        - git remote -v
+        - git remote set-url origin https://github.com.cnpmjs.org/discourse/discourse.git
+        - gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
         - git reset --hard
         - git clean -f
         - git remote set-branches --add origin master
@@ -145,6 +148,7 @@ run:
       hook: web
       cmd:
         # ensure we are on latest bundler
+        - gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
         - gem update bundler
         - find $home ! -user discourse -exec chown discourse {} \+

@@ -152,6 +156,9 @@ run:
       cd: $home
       hook: bundle_exec
       cmd:
+        - su discourse -c 'gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/'
+        - su discourse -c 'gem update bundler'
+        - su discourse -c 'bundle config mirror.https://rubygems.org https://gems.ruby-china.com'
         - su discourse -c 'bundle install --deployment --retry 3 --jobs 4 --verbose --without test developme

   - exec:
...skipping...

关于邮箱设置的问题

论坛通常需要有一个邮箱服务器,用于发送各种验证码,登录消息或者密码找回,消息提醒等功能。

网易的免费企业邮箱(ym.163.com)可以满足这个需求,使用qq邮箱开启smtp服务也是可以,当然也可以购买收费的邮箱。

网易免费企业邮箱默认是开启smtp服务的,下面是设置app.yml的例子: Discourse好像不提供支持ssl的连接方式,这里直接使用smtp服务了。 注意这里要显示关闭start_tls功能。

  DISCOURSE_SMTP_ADDRESS: smtp.ym.163.com
  DISCOURSE_SMTP_PORT: 25
  DISCOURSE_SMTP_USER_NAME: mail@getblog.cn
  DISCOURSE_SMTP_PASSWORD: "password"
  DISCOURSE_SMTP_ENABLE_START_TLS: false           # (optional, default true)
  DISCOURSE_SMTP_DOMAIN: getblog.cn    # (required by some providers)

另外,网站管理员的邮箱不可与 DISCOURSE_SMTP_USER_NAM相同,否则可能会收不到注册邮件。

Docker安装Discourse论坛/BBS系统(Nginx)

如果你身在大陆,则需要进行镜像加速。找到配置文件中的templates块,添加国内镜像templates/web.china.template.yml

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/sshd.template.yml"
  - "templates/web.template.yml"
  - "templates/web.china.template.yml"

显然这是由于 bundle install 造成的。这个操作即使服务器在境外都久,何况你还要爬一层墙。
后面 yarn install 的时候也要小心这个问题。

最好还是别把服务器放大陆吧,连从github上clone discourse本体都可能给你爆个错误……


For developers in China: Apparently this problem is due to bundle install . Even if the server is deployed in a foreign country, this operation will take a long time. Not to mention you’ll run into some well-known resistance.
Be careful about the same problem when yarn install later.

It’s better not to put the server in China, because even cloning discourse from github may give you an error…

谢谢回复!

服务器有代理,能正常访问GitHub,gem/bundle查到换国内源的教程,现在已经可以正常部署了(但是又卡在内存不够🥹

我也想弄太外网的服务器,太贵了🥹

中国的服务器有的比国外的都还贵(对,就是你阿里云),这个看厂商了。
等下 你还真选的阿里云啊……啊这

用的学生机(2核2G) :sweat_smile:
配置高点的服务器就没法承担了

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.