如何解决几天后停止 actionCable
Hi everybody,I want to use binance websocket and show in view with ActionCable. I created file `lib/ticker.rb` as below:
require 'faye/websocket'
require 'eventmachine'
require 'json'
Faye::WebSocket.load_adapter('thin')
EM.run do
ws = Faye::WebSocket::Client.new("wss://stream.binance.com:9443/stream?streams=ethusdt@ticker/btcusdt@ticker")
ws.on :message do |event|
response = JSON.parse(event.data)
if response['stream'].split("@")[1] == 'ticker' && response['data']['s'][-4..-1] == 'USDT')
ActionCable.server.broadcast 'ticker_channel',stream: response['stream'],content: response['data']
end
end
end
Then I created systemctl to run it as below:
[Unit]
Description=Thin Binance Ticker
After=syslog.target network.target
[Service]
Type=simple
WorkingDirectory=/usr/share/Nginx/html/myproject
ExecStart=/usr/local/rvm/gems/ruby-2.6.5/wrappers/bundle exec thin start -R lib/ticker.rb -p 9292
User=root
Group=root
RestartSec=1
Restart=always
[Install]
WantedBy=multi-user.target
But after a few days of starting it,the ActionCable does not work but the systemctl status is active! I have to restart the systemctl manually,to work ActionCable again. Anyone have an idea?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。