【GitLab】记GitLab Puma 8080 端口冲突解决

GitLab 13.0 开始,Puma 是默认的应用程序服务器. 计划在 GitLab 14.0 中删除对 Unicorn 的支持.

Puma 具有多线程体系结构,与像 Unicorn 这样的多进程应用程序服务器相比,它使用的内存更少. 在 GitLab.com 上,我们发现内存消耗减少了 40%.

大多数 Rails 应用程序请求通常都包含一定比例的 I / O 等待时间. 在 I / O 等待时间内,MRI Ruby 将释放 GVL(全局 VM 锁定)到其他线程. 因此,多线程 Puma 仍然可以处理比单个进程更多的请求.


环境:

CentOS 7.9
GitLab 13.10.3
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION # 查看版本

解决:

1.修改 puma.rb 配置

vim /var/opt/gitlab/gitlab-rails/etc/puma.rb

# Bind the server to "url". "tcp://", "unix://" and "ssl://" are the only
# accepted protocols.
bind 'unix:///var/opt/gitlab/gitlab-rails/sockets/gitlab.socket'

bind 'tcp://127.0.0.1:8092' ## 默认8080,修改为自己服务不冲突的端口,这里我改为8092

directory '/var/opt/gitlab/gitlab-rails/working'

workers 6

require_relative "/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/cluster/lifecycle_events"
require_relative "/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/cluster/puma_worker_killer_initializer"

on_restart do


2. 修改gitlab.rb 配置

vim /etc/gitlab/gitlab.rb

################################################################################
## GitLab Puma
##! Tweak puma settings. You should only use Unicorn or Puma, not both.
##! Docs: https://docs.gitlab.com/omnibus/settings/puma.html
################################################################################

# puma['enable'] = true
# puma['ha'] = false
# puma['worker_timeout'] = 60
# puma['worker_processes'] = 2
# puma['min_threads'] = 4
# puma['max_threads'] = 4

### Advanced settings
# puma['listen'] = '127.0.0.1'
puma['port'] = 8092 # 默认8080,去掉注释修改为同 `puma.rb` 中配置的端口:8092
# puma['socket'] = '/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket'
# puma['somaxconn'] = 1024

# puma['pidfile'] = '/opt/gitlab/var/puma/puma.pid'
# puma['state_path'] = '/opt/gitlab/var/puma/puma.state'

###! **We do not recommend changing this setting**
# puma['log_directory'] = "/var/log/gitlab/puma"

### **Only change these settings if you understand well what they mean**
###! Docs: https://github.com/schneems/puma_worker_killer
# puma['per_worker_max_memory_mb'] = 850

# puma['exporter_enabled'] = false
# puma['exporter_address'] = "127.0.0.1"
# puma['exporter_port'] = 8083


3. 生效配置,重启GitLab服务

gitlab-ctl reconfigu
gitlab-ctl restart


4. 检查端口情况

查询到有8092端口说明,服务启动正常配置生效。

netstat -tunlp | grep 端口号
在这里插入图片描述

  • 7
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值