0%

fpm
The goal of fpm is to make it easy and quick to build packages such as rpms, debs, OSX packages, etc.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
yum install ruby-devel gcc make rpm-build rubygems
gem sources -a https://mirrors.aliyun.com/rubygems/
gem sources --list
gem install fpm

fpm -p outdir -s dir -t rpm -n website --iteration 1.el6 -d aaa -d psmisc -v 1.0.1 -C ~/hello/

## -p 输出目录
## -d 依赖
## -v 版本
## -n name
## -C 包目录,~/hello/ => /
## ~/hello/usr/bin/hello => /usr/bin/hello

玩家反馈,ios15无法登录游戏,android和ios其他版本没有问题

分析发现,ios15将原本是一条数据内容分成三份发送

1
2
3
4
5
6
7
8
## 本来这应该是一条数据的
## FIN - Payload len
websocket:request:53 [mfa:proc_lib:init_p/5] parse_frames:{ssl,hybi,<<130,131>>,{ssl,{sslsocket,{gen_tcp,#Port<0.17851>,tls_connection,<0.533.0>},<0.6628.124>}}}
## Masking-key
websocket:request:53 [mfa:proc_lib:init_p/5] parse_frames:{ssl,hybi,<<153,193,1,85>>,{ssl,{sslsocket,{gen_tcp,#Port<0.17851>,tls_connection,<0.533.0>},<0.6628.124>}}}
## Payload Data
websocket:request:53 [mfa:proc_lib:init_p/5] parse_frames:{ssl,hybi,<<190,209,15>>,{ssl,{sslsocket,{gen_tcp,#Port<0.17851>,tls_connection,<0.533.0>},<0.6628.124>}}}

对应的协议格式:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-------+-+-------------+-------------------------------+
|F|R|R|R| opcode|M| Payload len | Extended payload length |
|I|S|S|S| (4) |A| (7) | (16/63) |
|N|V|V|V| |S| | (if payload len==126/127) |
| |1|2|3| |K| | |
+-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
| Extended payload length continued, if payload len == 127 |
+ - - - - - - - - - - - - - - - +-------------------------------+
| |Masking-key, if MASK set to 1 |
+-------------------------------+-------------------------------+
| Masking-key (continued) | Payload Data |
+-------------------------------- - - - - - - - - - - - - - - - +
: Payload Data continued ... :
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
| Payload Data continued ... |
+---------------------------------------------------------------+

对于使用mochiweb的websocket只要增加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
parse_hybi_frames(_, <<>>, Acc) ->
lists:reverse(Acc);

......此处省略N行

%% 数据不完整,继续收
parse_hybi_frames(Socket, PartFrame, Acc) ->
%% io:format("3 ~p ~n",[{_Fin,_Rsv,_Opcode,_Mask,_PayloadLen,_MaskKey}]),
ok = mochiweb_socket:exit_if_closed(mochiweb_socket:setopts(Socket, [{packet, 0}, {active, once}])),
receive
{tcp_closed, _} ->
mochiweb_socket:close(Socket),
exit(normal);
{ssl_closed, _} ->
mochiweb_socket:close(Socket),
exit(normal);
{tcp_error, _, _} ->
mochiweb_socket:close(Socket),
exit(normal);
{Proto, _, Continuation} when Proto =:= tcp orelse Proto =:= ssl ->
parse_hybi_frames(Socket, <<PartFrame/binary, Continuation/binary>>,
Acc);
_ ->
mochiweb_socket:close(Socket),
exit(normal)
after
5000 ->
mochiweb_socket:close(Socket),
exit(normal)
end.

其他语言也差不多的逻辑,数据不全就继续等待数据了

参考文档

  1. https://datatracker.ietf.org/doc/html/draft-ietf-hybi-thewebsocketprotocol-10

最近查看公司机器的内存占用情况,发现mongod大约占了50%的内存。
命令:ps auxc|head -1;ps auxc|grep -v PID|sort -rn -k +4|head;
原来内存默认使用的是(系统内存-1GB)*50%(据说是3.4版本+)。

这也太坑了,服务器又不是专门用作DB的,还有其他进程也要吃内存。

运行中的mongod,也不敢restart,查询了可能的运行中清理内存。
注意:没有在正式环境中执行过,仅作参考。

阅读全文 »

server端

下载地址:

安装到自己的手机上,然后点击右上角的+,添加需要共享的视频/音频
确保可以后台运行

client端

下载VLC for Android
安装到某盒子或者智能电视
确保server端client端在同一个局域网中

打开VLC,稍等片刻就可以在本地网络中看到了
如果看不到的话,就重启下server端