我想听听各位如果现在新建一个项目,要不要做成单页
Ruby on rials?
是端口没映射
ports:
- "80:80"
- "3002:3002"
现在就差最后一步了,结果出来这么个报错NoMethodError (private method
warn' called for nil:NilClass):`
I, [2018-03-25T08:26:14.073013 #22] INFO -- : [5083dc64-fb14-4d47-b359-6c7ad6d836f7] Completed 500 Internal Server Error in 43ms
F, [2018-03-25T08:26:14.078556 #22] FATAL -- : [5083dc64-fb14-4d47-b359-6c7ad6d836f7]
F, [2018-03-25T08:26:14.080239 #22] FATAL -- : [5083dc64-fb14-4d47-b359-6c7ad6d836f7] NoMethodError (private method `warn' called for nil:NilClass):
F, [2018-03-25T08:26:14.080579 #22] FATAL -- : [5083dc64-fb14-4d47-b359-6c7ad6d836f7]
F, [2018-03-25T08:26:14.080940 #22] FATAL -- : [5083dc64-fb14-4d47-b359-6c7ad6d836f7] exception_notification (4.2.1) lib/exception_notifier.rb:109:in `rescue in fire_notification'
[5083dc64-fb14-4d47-b359-6c7ad6d836f7] exception_notification (4.2.1) lib/exception_notifier.rb:103:in `fire_notification'
[5083dc64-fb14-4d47-b359-6c7ad6d836f7] exception_notification (4.2.1) lib/exception_notifier.rb:48:in `block in notify_exception'
[5083dc64-fb14-4d47-b359-6c7ad6d836f7] exception_notification (4.2.1) lib/exception_notifier.rb:47:in `each'
[5083dc64-fb14-4d47-b359-6c7ad6d836f7] exception_notification (4.2.1) lib/exception_notifier.rb:47:in `notify_exception'
[5083dc64-fb14-4d47-b359-6c7ad6d836f7] exception_notification (4.2.1) lib/exception_notification/rack.rb:42:in `rescue in call'
[5083dc64-fb14-4d47-b359-6c7ad6d836f7] exception_notification (4.2.1) lib/exception_notification/rack.rb:31:in `call'
现在 nginx 也生效了,我想试着绑在 3002 端口下看下效果,但是并没有反应,80 端口是好的
nginx
upstream bkfix {
server bkfix:7000 fail_timeout=0;
}
server {
listen 3002 default_server;
root /var/www/bkfix/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
docker-compose
version: '3'
services:
bkfix:
build: .
command: bundle exec puma -C config/puma.rb -e production
environment:
- RAILS_ENV=production
ports:
- "7000:7000"
volumes:
- .:/app
links:
- mysql
- redis
mysql:
image: mysql
restart: always
command: --character-set-server=utf8 --collation-server=utf8_general_ci
environment:
- MYSQL_ROOT_PASSWORD=ad66544970123
- MYSQL_DATABASE=bkfix_dev
volumes:
- ./data/mysql:/var/lib/mysql
redis:
image: redis:alpine
command: redis-server
volumes:
- ./data/redis:/data
web:
image: nginx
links:
- bkfix
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "80:80"
puma.rb
app_root = "/app"
pidfile "#{app_root}/tmp/pids/puma.pid"
state_path "#{app_root}/tmp/pids/puma.state"
bind "unix://#{app_root}/tmp/sockets/puma.sock"
port 7000
activate_control_app "unix://#{app_root}/tmp/sockets/pumactl.sock"
# daemonize true
workers 2
threads 8, 16
preload_app!
stdout_redirect "#{app_root}/log/puma_access.log", "#{app_root}/log/puma_error.log", true
on_worker_boot do
ActiveSupport.on_load(:active_record) do
ActiveRecord::Base.establish_connection
end
end
before_fork do
ActiveRecord::Base.connection_pool.disconnect!
end
web:
image: nginx
links:
- bkfix
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
command: nginx -c /etc/nginx/nginx.conf
ports:
- "80:80"
我想让我的 nginx.conf 生效,但是我 nginx 只要加上command: nginx -c /etc/nginx/nginx.conf
跑就会直接退出,不知道怎么回事,
我还想问下各位大佬,如果想用 docker 来部署 production,正确的流程应该是怎么样的,本地 Build 完,传上去,到服务器 Pull 下来跑,还是到服务器上 build,感觉比起一句mina deploy
来说,docker 部署步骤还挺多的
现在又碰到一个问题,我 link 了一个 redis,但是我的 rails 默认找的是 127.0.0.1:6379,而 redis 在另一个容器里面,rails 容器得用 redis:6379 来访问,这个怎么处理比较妥一点
version: '3'
services:
bkfix:
build: .
command: rails s -p 4000
ports:
- "3000:4000"
volumes:
- .:/app
links:
- mysql
- redis
mysql:
image: mysql
restart: always
command: --character-set-server=utf8 --collation-server=utf8_general_ci
ports:
- '3306:3306'
environment:
- MYSQL_ROOT_PASSWORD=ad66544970123
- MYSQL_DATABASE=bkfix_dev
volumes:
- ./data/mysql:/var/lib/mysql
redis:
image: redis:alpine
command: redis-server
volumes:
- ./data/redis:/data
这样啊,那数据库呢,装在一起,还是新建一个容器 link
确实是因为服务器上没有application.rb
,问题解决了
找到原因了
不是"AES-128-ECB"
是"AES-128-CBC"
顺便贴一下官方的 nodeJs 版本
var crypto = require('crypto')
function WXBizDataCrypt(appId, sessionKey) {
this.appId = appId
this.sessionKey = sessionKey
}
WXBizDataCrypt.prototype.decryptData = function (encryptedData, iv) {
// base64 decode
var sessionKey = new Buffer(this.sessionKey, 'base64')
encryptedData = new Buffer(encryptedData, 'base64')
iv = new Buffer(iv, 'base64')
try {
// 解密
var decipher = crypto.createDecipheriv('aes-128-cbc', sessionKey, iv)
// 设置自动 padding 为 true,删除填充补位
decipher.setAutoPadding(true)
var decoded = decipher.update(encryptedData, 'binary', 'utf8')
decoded += decipher.final('utf8')
decoded = JSON.parse(decoded)
} catch (err) {
throw new Error('Illegal Buffer')
}
if (decoded.watermark.appid !== this.appId) {
throw new Error('Illegal Buffer')
}
return decoded
}
module.exports = WXBizDataCrypt
我想问下本地开发用 docker,容器外代码改了让容器内的 server 生效呢
加了 i 果然好了。
多谢大佬,话说这个项目就是借鉴了你的https://github.com/rails-engine/exception-track
赶紧把webpacker
弄的好用一些才是正道啊
现在的趋势不就是一个网站就一个 tag 吗
target='_blank'
你换中文或者正常的单词试试
你们的网站里面用的都是英文吗,英文也很少有ss
这种数据吧
accepts_nested_attributes_for
果断升级到 high sierra,好了
dyld: mach-o, but built for simulator (not macOS)
Could not open library 'libfib.dylib': dlopen(libfib.dylib, 5): image not found
为什么我的扩展打不开。 macos 10.12 好像有坑,lz 版本多少
四斋蒸鹅心
把 IP 存起来,丢到 redis?
那那个OPTIONS
请求是做什么用的
解决了,
写一个你需要被跨域访问时的OPTIONS
路由
routes.rb
match '/api/v1/cards/:id', :controller => 'option_configs', :action => 'options', :via => :options
option_configs_controller.rb
class OptionConfigsController < ApplicationController
def options
headers['Access-Control-Allow-Origin'] = "*"
headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS, PUT'
headers['Access-Control-Allow-Headers'] = 'Content-Type'
head :ok
end
end
Vue 会把 html 文件弄得一团糟,相比 React 的 JSX 来说,Vue 用起来真的不是很舒服
我还以为是我水平不够才觉得难用的,看到管理员说这句话我就放心了。
我临时写了一个比较符合 ES 的
class MyDsl
def initialize
@hash = {}
end
def method_missing method_name, k=nil, v=nil, &block
if block_given?
new_container = self.class.new
new_container.instance_eval(&block)
@hash[method_name] = new_container.to_h
else
@hash[method_name] ||= {}
@hash[method_name][k] = v
end
end
def to_h
@hash
end
end
es = MyDsl.new
es.bool do
must do
match 'title', 'test'
end
end
es.to_h
=> {:bool=>{:must=>{:match=>{"title"=>"test"}}}}