Obsapidelayed.service 启动失败

在 Leap 42.1 上搭建 obs,使用的 OBS:Server:Unstable 源,obs-server, obs-worker, obs-api 安装都正常。
但是 obsapidelayed.service 启动失败:

linux-dexl:~ # systemctl start obsapidelayed.service
Job for obsapidelayed.service failed. See "systemctl status obsapidelayed.service" and "journalctl -xn" for details.
linux-dexl:~ # journalctl  -xn
-- Logs begin at Sun 2016-01-24 22:27:24 EST, end at Tue 2016-01-26 04:19:51 EST. --
Jan 26 04:19:50 linux-dexl obsapidelayed[15733]: from /usr/lib64/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/railtie.rb:194:in `public_send'
Jan 26 04:19:50 linux-dexl obsapidelayed[15733]: from /usr/lib64/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/railtie.rb:194:in `method_missing'
Jan 26 04:19:50 linux-dexl obsapidelayed[15733]: from /srv/www/obs/api/config/environment.rb:30:in `<top (required)>'
Jan 26 04:19:50 linux-dexl obsapidelayed[15733]: from script/delayed_job.api.rb:3:in `require'
Jan 26 04:19:50 linux-dexl obsapidelayed[15733]: from script/delayed_job.api.rb:3:in `<main>'
Jan 26 04:19:50 linux-dexl obsapidelayed[15733]: ..failed
Jan 26 04:19:51 linux-dexl obsapidelayed[15733]: Starting OBS api clock daemon clockworkd.clock: pid file: /srv/www/obs/api/tmp/clockworkd.clock.pid
Jan 26 04:19:51 linux-dexl obsapidelayed[15733]: clockworkd.clock: output log file: /srv/www/obs/api/log/clockworkd.clock.output
Jan 26 04:19:51 linux-dexl obsapidelayed[15733]: clockworkd.clock: process with pid 15776 started.
Jan 26 04:19:51 linux-dexl obsapidelayed[15733]: ..done

看不懂 ruby,网上也没有类似问题。 :joy:

已安装的 obs 相关包:

linux-dexl:~ # rpm -qa | grep obs
obs-productconverter-2.6.51.git20160125.fdf944f-1653.1.noarch
obs-signd-2.2.1-1.1.x86_64
obs-common-2.6.51.git20160125.fdf944f-1653.1.noarch
obs-worker-2.6.51.git20160125.fdf944f-1653.1.noarch
obs-api-2.6.51.git20160125.fdf944f-1653.1.noarch
obs-server-2.6.51.git20160125.fdf944f-1653.1.noarch

好像 environment.rb:30 出错了。但感觉那处代码可能是 require ‘railties’ 或者 require ‘rail’

public_send 是 rails 里面很常见的函数,一个功能是把 String 类的比如 “>=” 转换成 operator,不然类似 “2 >= 1” 这种字符串是无法判断大小返回 true/false 的。

str = "2 >= 1"
arr = str.split(/\s/) # 按空格切成数组
if arr[0].public_send(arr[1]) arr[2]
    return true
else
    return false
end

这个错误可能是说你该给字符串类型的 operator 的时候你给了别的,比如只能认 “>=”, “>”, “<=”, “<” 的时候你传进去了一个 “!=” 就会出错。

明天我再具体看下,估计是你配置文件哪里写错了。

environment 我进去看了下,出错的那一行并没有看出什么名堂。
另外苏姐你给的代码里这一句是不是应该没有"." 啊,如果我没有理解错是不是应该是这样:

if arr[0] public_send(arr[1]) arr[2]

我把相关的几个文件贴了上来,我都进去看了下,没看懂哪里出了错,麻烦苏姐看一眼,整个 obs appliance 搭建就剩这里过不去,其他的都搞好了(包括 obssigner 服务也起来了)。

obsapidelayed.tar.gz (3.17 KB)

必须有 “.”。public_send 是 Obj 对象的方法。ruby 里所有东西都是 Obj 对象。

从我的 iPhone 发送,使用 Tapatalk

嗯,类似于 python 里的“列表. 方法”, 了解。
environment.rb:30 的内容是这样的:

OBSApi::Application.initialize!

railtie.rb:194 的内容:

instance.public_send(name, *args, &block)

delayed_job.api.rb:3 的内容:

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))

是不是理解为把 OBSApi Application initialize 传给 name *args &block 呢

问题貌似出在这里:设置 api_production database 时没有成功,所以后面 obsapidelayed 服务起不来

Icy@linux-dexl:/srv/www/obs/api> sudo RAILS_ENV="production" rake -f Rakefile  db:create
Icy@linux-dexl:/srv/www/obs/api> sudo RAILS_ENV="production" rake -f Rakefile  db:setup
Seeding architectures table...
Seeding roles table...
Seeding users table...
Seeding roles_users table...
Seeding static_permissions table...
Seeding static permissions for admin role in roles_static_permissions table...
Seeding static permissions for maintainer role in roles_static_permissions table...
Seeding static permissions for reader role in roles_static_permissions table...
Seeding static permissions for downloader role in roles_static_permissions table...
Seeding attrib_namespaces table...
Seeding attrib_types table...
Seeding issue trackers ...
rake aborted!
ActiveRecord::StatementInvalid: Mysql2::Error: Data truncated for column 'kind' at row 1: INSERT INTO `issue_trackers` (`name`, `description`, `kind`, `regex`, `url`, `label`, `show_url`, `issues_updated`) VALUES ('obs', 'OBS GitHub Issues', 'github', 'obs#(\\d+)', 'https://api.github.com/repos/openSUSE/open-build-service/issues', 'obs#@@@', 'https://github.com/openSUSE/open-build-service/issues/@@@', '2016-02-01 19:00:41')
/srv/www/obs/api/db/seeds.rb:295:in `<top (required)>'
/srv/www/obs/api/lib/tasks/databases.rake:91:in `block (2 levels) in <top (required)>'
Mysql2::Error: Data truncated for column 'kind' at row 1
/srv/www/obs/api/db/seeds.rb:295:in `<top (required)>'
/srv/www/obs/api/lib/tasks/databases.rake:91:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:seed

我看你都往里面 seeding 了,就假设你之前命令行下面 mysql 数据库的初始化、创建都正确。

那是 mysql2 数据库的问题。你试试在 database.yml 里加上 strict:false。

stackoverflow.com/questions/24310178/rails-4-migration-mysql2error-data-too-long-for-column-xxxx

PS:OBS:Server:Unstable 现在没有 TW 能用的包,我不能单架一个 obs-api 来测试。

刚看到你在 mailing list 上问了,nice try!Adrian 还回了,他是 OBS 的第一作者,你可以不用找我这个不会 Rails 的 Rubyist 了 :joy:

mysql_secure_installation 和 api_production database 创建都是没问题的,这个很确定。只是 setup 那一步过不去,我进 mysql 去看 seeding 的内容,没什么特别的,有可能真是 data too long。
毕竟是 unstable 的 repo,我升级 obs-api 后这个问题就消失了,create 和 setup 都正常通过。
不过 obsapidelayed 服务还是起不来,不是 mysql 的锅。

嗯,没想到原因只是因为 /srv/www/obs/api/log/backend_access.log 的权限不对,我偷懒改成 777 后 obsapidelayed 服务就正常启动了。

但是我也从来没改过这个文件的权限啊,所以我给 Adrian 回信提了一下这可能是个问题。

plus:苏姐又自黑,哪里有不会 rails 的 Rubyist 啊 :tongue: