我正在尝试使用Rails 4的直播流实现文本/事件流.它工作得很好,我遇到的唯一麻烦就是我无法在不发送任何消息的情况下检查连接是否存在.
我想出的唯一解决方案是使用循环刻度生成器创建支持通道,以便某些后台任务将定期发送消息.但它似乎是凌乱和不可靠的.更好的解决方案?
这是我的控制器:
require 'persistency/sse'
require 'persistency/track'
class PersistencyController < ApplicationController
include ActionController::Live
def stream
response.headers['Content-Type'] = 'text/event-stream'
sse = Persistency::SSE.new(response.stream)
track = Persistency::Track.new(current_user)
redis = Redis.new
begin
redis.subscribe(:info, :chat) do |on|
on.message do |channel, message|
sse.write({ :message => message }, :event => channel)
end
end
rescue IOError
ensure
track.close
sse.close
end
end
end
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Scala 2.11.6和Play 从Akka actor设置调试日志到控制台2.4.6.所以我看到这个配置的信息消息,但没有调试:
application.conf:
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
level = "DEBUG"
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
}
Run Code Online (Sandbox Code Playgroud)
logback.xml:
<logger name="akka" level="DEBUG" />
<logger name="actors" level="DEBUG" />
Run Code Online (Sandbox Code Playgroud)
用法:
package actors
import akka.actor._
import akka.event.Logging
object DispatchActor {
def props(out: ActorRef) = Props(new DispatchActor(out))
}
class DispatchActor(out: ActorRef) extends Actor {
val log = Logging(context.system, this)
log.debug("akka started: info")
def receive = {
case msg: String =>
log.debug("actor received a message")
out ! ("I received your message: " + …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用nginx 1.9.11将位置代理到websocket上游.这是配置摘录:
upstream autocloud_dispatcher {
server 127.0.0.1:4000 fail_timeout=0;
}
server {
.....
location /ws {
proxy_pass http://autocloud_dispatcher;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_connect_timeout 7d;
proxy_send_timeout 7d;
proxy_read_timeout 7d;
}
}
Run Code Online (Sandbox Code Playgroud)
除此之外,我每隔90秒从支持发送ping消息.但是连接每2分钟仍然断开连接.nginx中的其他一些设置默认为120s?
我将PostGIS与Postgresql一起使用,以便能够通过存储在location列中的坐标在某个半径内找到条目Geometry/Point SRID: 4326。这是我正在尝试的两个查询:
第一个距离以米为单位且use_spheroid = true
EXPLAIN ANALYZE SELECT count(*) FROM "cars" WHERE ST_DWithin(location, ST_SetSRID(ST_MakePoint(20, -30), 4326), 105000, true) LIMIT 1000;
QUERY PLAN
--------------
Limit (cost=11884.28..11884.30 rows=1 width=8) (actual time=18.843..18.844 rows=1 loops=1)
-> Aggregate (cost=11884.28..11884.30 rows=1 width=8) (actual time=18.842..18.843 rows=1 loops=1)
-> Seq Scan on cars (cost=0.00..11883.33 rows=381 width=0) (actual time=0.486..18.827 rows=38 loops=1)
Filter: (((location)::geography && '0101000020E610000000000000000034400000000000003EC0'::geography) AND ('0101000020E610000000000000000034400000000000003EC0'::geography && _st_expand((location)::geography, '105000'::double precision)) AND _st_dwithin((location)::geography, '0101000020E610000000000000000034400000000000003EC0'::geography, '105000'::double precision, true))
Rows Removed by Filter: 28549
Planning time: 0.166 ms …Run Code Online (Sandbox Code Playgroud) 如何为TableCell设置转换器以能够编辑Double属性?
<TableColumn fx:id="priceCol" text="Price">
<cellValueFactory>
<PropertyValueFactory property="price" />
</cellValueFactory>
<cellFactory>
<TextFieldTableCell fx:factory="forTableColumn">
<converter>
// ???
</converter>
</TextFieldTableCell>
</cellFactory>
</TableColumn>
Run Code Online (Sandbox Code Playgroud)
在哪里可以找到有关如何使用FXML设置此类文档的文档?到目前为止,这看起来确实令人困惑。
我正在尝试创建自定义 docker 映像,以便将其用作 AWS CodeBuild 的构建映像。docker build如果我只是通过设置环境来针对 Dockerfile进行操作,则效果很好。但现在我需要添加一个 postgres 实例来运行测试。所以我认为使用docker-compose可以解决问题。但是我无法弄清楚如何使其发挥作用。当我尝试时,组合的静态部分(来自 Dockerfile 的图像)似乎立即停止docker-compose up,因为没有入口点。此时,我可以通过运行连接到数据库实例docker-compose run db psql -h db -U testdb -d testdb。但是,当我构建它并将其提供给 AWS 提供的脚本时,它运行良好,直到我的测试尝试到达数据库服务器。这是它因超时而失败的地方,就好像没有数据库实例一样。
配置看起来像这样:
version: '3.7'
services:
api-build:
tty: true
build: ./api_build
image: api-build
depends_on:
- db
db:
image: postgres:10-alpine
restart: always
environment:
POSTGRES_USER: testdb
POSTGRES_PASSWORD: testdb
Run Code Online (Sandbox Code Playgroud)
和 Dockerfile 下./api_build:
FROM alpine:3.8
FROM ruby:2.3-alpine as rb
RUN apk update && apk upgrade && \
echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories …Run Code Online (Sandbox Code Playgroud)