故障处理

故障处理

1 启动内存数据库失败

$ systemctl start yjj
$ systemctl status yjj
* yjj.service - Yi Jin Jing
   Loaded: loaded (/opt/kungfu/yijinjing/etc/systemd/user/yjj.service; linked; vendor preset: disabled)
   Active: inactive (dead)

Jan 18 09:52:56 134e68827fd8 kungfu[535]: File "/usr/lib/python2.7/site-packages/pid/__init__.py", line 206, in __enter__
Jan 18 09:52:56 134e68827fd8 kungfu[535]: self.create()
Jan 18 09:52:56 134e68827fd8 kungfu[535]: File "/usr/lib/python2.7/site-packages/pid/__init__.py", line 172, in create
Jan 18 09:52:56 134e68827fd8 kungfu[535]: check_result = self.check()
Jan 18 09:52:56 134e68827fd8 kungfu[535]: File "/usr/lib/python2.7/site-packages/pid/__init__.py", line 156, in check
Jan 18 09:52:56 134e68827fd8 kungfu[535]: return inner_check(self.fh)
Jan 18 09:52:56 134e68827fd8 kungfu[535]: File "/usr/lib/python2.7/site-packages/pid/__init__.py", line 144, in inner_check
Jan 18 09:52:56 134e68827fd8 kungfu[535]: raise PidFileAlreadyRunningError("Program already running with pid: %d" % pid)
Jan 18 09:52:56 134e68827fd8 kungfu[535]: pid.PidFileAlreadyRunningError: Program already running with pid: 535
Jan 18 09:52:56 134e68827fd8 kungfu[537]: ('Failed in shutdown', (<class 'socket.error'>, error(111, 'Connection refused'), <traceback object at 0x1aede18>))

现象:启动yjj内存数据库服务,使用 systemctl status yjj 查看状态,发现状态为 Active: inactive (dead),即启动不成功。

原因分析:’socket.error’ “Program already running with pid: %d” % pid,等项目表明系统认为已经有服务启动了,而实际上服务并没有启动,是因为系统记录了服务的pid号在/shared/kungfu/pid目录下,如果在系统运行时宿主机或者docker被关闭,可能出现/shared/kungfu/pid目录下文件被以更高权限进行了修改,导致内存数据库启动时无法重新写入。可以将该目录修改为bruce权限,再重启内存数据库服务 yjj 即可,操作如下:

$ cd /shared/
$ sudo chown -R bruce:bruce kungfu/
$ systemctl start yjj

2 行情交易无法连接

$ wingchunctl
md_ctp                           RUNNING   pid 22281, uptime 0:02:32
td_ctp                           EXITED    Jan 19 04:46 PM
$ tail /shared/kungfu/log/wingchun/td_ctp_out.log
[18-01-19 16:46:12.657] [INFO ] [engine.trade.ctp] IEngine::init NeedSettleConfirm->true
[18-01-19 16:46:12.657] [INFO ] [engine.trade.ctp] IEngine::init accounts->[{"clients":["demo1","demo2"],"info":{"BrokerId":"***","InvestorId":"****","Password":"****","UserId":"***"},"is_default":true}]
[18-01-19 16:46:12.657] [INFO ] [engine.trade.ctp] [account] number: 1
[18-01-19 16:46:12.657] [INFO ] [engine.trade.ctp] [client] (name)demo1 (account)****
[18-01-19 16:46:12.657] [INFO ] [engine.trade.ctp] [client] (name)demo2 (account)****
[18-01-19 16:46:12.672] [INFO ] [engine.trade.ctp] [OnFrontConnected] (idx)0
tun0: Success
docker0: Invalid argument
eno4: Invalid argument
[18-01-19 16:46:12.697] [ERROR] [engine.trade.ctp] [OnRspUserLogin] (errId)3 (errMsg)CTP:不合法的登录

现象:连接交易接口发现无法连接成功,查看该交易接口日志发现有错误日志 不合法的登录

原因分析:行情交易接口会将其收到的交易所错误回报直接打印到日志中,从日志中可以看出,(errMsg)CTP:不合法的登录,返回了登录错误的信息:不合法登录,一般是由于账户用户名或密码信息错误导致.