红联Linux门户
Linux帮助

ubuntu 15.04 gitlab出现initctl:unable to connect to Upstart

发布时间:2015-05-06 15:44:46来源:http://jianxuan.li/作者:李建轩

升级了ubuntu15.04后今天启动gitlab发生这样一个错误:
Running handlers:
[2015-05-06T11:31:46+08:00] ERROR: Running exception handlers
Running handlers complete

[2015-05-06T11:31:46+08:00] ERROR: Exception handlers complete
[2015-05-06T11:31:46+08:00] FATAL: Stacktrace dumped to /opt/gitlab/embedded/cookbooks/cache/chef-stacktrace.out
Chef Client failed. 1 resources updated in 62.292182162 seconds
[2015-05-06T11:31:46+08:00] ERROR: execute[initctl status gitlab-runsvdir] (runit::upstart line 29) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of initctl status gitlab-runsvdir ----
STDOUT:
STDERR: initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
---- End output of initctl status gitlab-runsvdir ----
Ran initctl status gitlab-runsvdir returned 1
[2015-05-06T11:31:46+08:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)


结束之后抛出的信息里有这样一段:
Resource Declaration:
---------------------
# In /opt/gitlab/embedded/cookbooks/runit/recipes/upstart.rb

29: execute "initctl status gitlab-runsvdir" do
30:   retries 30
31: end
32:


我尝试执行了:
initctl status php5-fpm

之类的命令,都是提示
initctl: 无法连接到 Upstart: Failed to connect to socket /com/ubuntu/upstart: 拒绝连接


所以应该是命令有问题吧,网上搜索了一下,找到一个答案
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl

将/bin/true指向了 initctl,结果导致启动的时候用户无法登陆,又用单用户模式恢复过来。


继续查看了提示中的/opt/gitlab/embedded/cookbooks/runit/recipes/upstart.rb:29:

找到这样的代码
# Keep on trying till the job is found :(
execute "initctl status gitlab-runsvdir" do
retries 30
end

# If we are stop/waiting, start
#
# Why, upstart, aren't you idempotent? :(
execute "initctl start gitlab-runsvdir" do
only_if "initctl status gitlab-runsvdir | grep stop"
retries 30
end


我将initctl替换为了:
# Keep on trying till the job is found :(
#execute "initctl status gitlab-runsvdir" do
execute "/bin/true" do
retries 30
end

# If we are stop/waiting, start
#
# Why, upstart, aren't you idempotent? :(
#execute "initctl start gitlab-runsvdir" do
execute "/bin/true" do
only_if "initctl status gitlab-runsvdir | grep stop"
retries 30
end


然后再运行gitlab-ctl reconfigure,gitlab-ctl restart,它就又能正常工作了。


相关文章:
把你的Ubuntu 14.10系统升级成Ubuntu 15.04正式版:http://www.linuxdiyf.com/linux/11608.html

Ubuntu安装Gitlab:http://www.linuxdiyf.com/linux/1954.html

64位ubuntu15.04升级Linux内核到linux4.1.0:http://www.linuxdiyf.com/linux/11805.html