我在Rails 5应用程序上使用了actioncable。下面的代码在控制器中起作用,但在控制台中不起作用。
ActionCable.server.broadcast "connector_app", content: "test message"
Run Code Online (Sandbox Code Playgroud)
响应:
[ActionCable] Broadcasting to connector_app: {:content=>"test message"}
=> nil
Run Code Online (Sandbox Code Playgroud)
电缆
development:
adapter: redis
url: redis://localhost:6379/1
test:
adapter: async
production:
adapter: redis
url: redis://localhost:6379/1
Run Code Online (Sandbox Code Playgroud)
控制器代码(正常工作):
def sample_socket_message
ActionCable.server.broadcast "connector_app",
content: "test message",
head :ok
end
Run Code Online (Sandbox Code Playgroud)
解决的问题:忘记在config / initializer / redis.rb中添加以下代码
$redis = Redis.new(:host => 'localhost', :port => 6379)
Run Code Online (Sandbox Code Playgroud) 我是Rails的新手,不知道如何在Rails单个应用程序中访问多个数据库。
我会这样尝试
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password: root
socket: /var/run/mysqld/mysqld.sock
reconnect: true
development:
<<: *default
database: connection_development
<<: *default
database: connection_test
Run Code Online (Sandbox Code Playgroud)
log_database_production:
adapter: mysql2
encoding: utf8
pool: 5
host: 192.168.100.97
port: 3306 #ip address of server with other postgres database
username: root
password: root
database: hrms_development
reconnect: true
Run Code Online (Sandbox Code Playgroud)
那我不知道该怎么办..
我尝试在具有 1 个 CPU 和 2GB RAM 的服务器上使用 ffmpeg 处理 4GB 视频,但该命令挂起 5 分钟,然后启动并处理速度非常慢。以下是控制台输出:
命令
ffmpeg -i input.mp4 -filter_complex '[0:v]trim=823.2:867.3,setpts=PTS-STARTPTS[v0];[0:v]trim=1074.1:1101.4,setpts=PTS-STARTPTS[v1];[0:v]trim=1142.2:1198.9,setpts=PTS-STARTPTS[v2];[0:v]trim=1227.9:1320.0,setpts=PTS-STARTPTS[v3];[0:v]trim=1887.1:1990.8,setpts=PTS-STARTPTS[v4];[0:v]trim=2008.1:2091.3,setpts=PTS-STARTPTS[v5];[0:v]trim=3090.1:3105.1,setpts=PTS-STARTPTS[v6];[0:v]trim=3185.3:3222.2,setpts=PTS-STARTPTS[v7];[0:v]trim=3306.4:3336.5,setpts=PTS-STARTPTS[v8];[0:v]trim=3426.7:3465.7,setpts=PTS-STARTPTS[v9];[0:v]trim=3548.7:3586.5,setpts=PTS-STARTPTS[v10];[v0][v1][v2][v3][v4][v5][v6][v7][v8][v9][v10]concat=n=11:v=1[out]' -map '[out]' output.mp4
Run Code Online (Sandbox Code Playgroud)
输出
ffmpeg version 3.4.8-0ubuntu0.2 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack …Run Code Online (Sandbox Code Playgroud)