2015年3月15日 星期日

安裝於CentOS的supervisord無預警關閉 (crash with system time change - fixed)

有一隻自己寫的Linux程式跑在CentOS 6.6 x86_64上
寫的不好 執行發生錯誤時有可能會當掉
但為了某些原因它必須重新跑起來
[I installed supervisord 3.1.3 on CentOS 6.6 x86_64 to monitor a daemon
and to respawn it automatically whenever necessary]

網路文說supervisord是宣稱唯一不需要搶系統優先控制權的工具

簡單裝起來 只把自己的程式路徑名稱寫入設定檔
用預設值就跑起來了 以為一切就是這麼簡單美妙
[With almost everything in default value, supervisord started to run as exepcted]

第二天進系統檢查一下....


我的程式還苟活著 不錯

咦~ supervisord不見了 它......竟然掛了!
[However, surprise came to me on the second day. Supervisord crashed with no hint at all. It just gone!]


查遍各大論壇 終於看到有人po文表示:
自己的Linux時間常跑掉 用ntp對時後supervisord就無預警的掛了
[Some thread in a forum mentioned a symptom that supervisord crashes after ntpdate adjusted system time]

回測自己主機 確實在手動將時間往前調之後supervisord就閃退了
[I made some tests with manual 'date' command to turn back system time (hours). Oops! Same here: crash... crash... and crash.....]

再經過一番努力搜尋又測了三天 確認這個解法有用
[Luckily I found a solution by the honorable person "Mook-as". And his/hers solution was tested to work on my system]

 Use monotonic time for process state tracking by Mook-as

成因大致是supervisord處理time的方式讓它在系統時間倒退後出了問題
(例如某程序在檢查目前時間是否已到執行某工作時 發現自己回到過去了)

把所有time.time()換成monotonic_time()就好了
[For those who having the same problem as I did, apply the patch (I did it by manual input) to replace time.time() then it should work]

連結就是上方的標題

有相同需求的朋友請自行patch你的.py程式吧
[Thank you, Mook-as!]

cheers~

2015年2月24日 星期二

Tomato by Shibby之Access Restriction失效問題

為了限制部分電腦只能於特定時間上網
找了部Tenda N6改成Tomato by Shibby

設定Access Restriction功能後測試  無效!!!

電腦的IP位址已經被鎖了,卻仍可上網

挖出用過沒問題的無線路由器來比對

兩台路由器只有韌體版本不同

新: Tomato Firmware 1.28.0000 MIPSR2-124 K26 Max
舊: Tomato Firmware 1.28.0000 MIPSR2-123 K26 Max

直接將Tenda N6降版到123沒改設定,功能生效了

結論: 目前最新版v1.28 build 124的部分功能有問題

Function "Access Restriction" does not work properly in Tomato by Shibby v1.28 build 124. Pretty sure it's a bug in latest version because the same setting works after I downgrade firmware to v1.28 build 123.


2015年2月11日 星期三

kamailio IPv6運作超難搞 (失敗收場)


如果你想試試SIP/IPv6,很可能會搜尋到這篇文章:
Run your own SIP VoIP service on both IPv4 and IPv6


讀來如此簡單而美好

花兩天時間試過裝在以下各VM
CentOS 6.3 x86 (source編譯安裝)
Debian 7.7.0 i386 (source編譯安裝)
Debian 6.0.4 i386 (source編譯安裝)
Debian 7.0.0 i386 (直接從repo用apt-get安裝)

全部同樣的情況:
IPv4幾乎不需要設定就能動
IPv6怎麼設定5060 port都不收封包 (netstat確定有listen)

怎麼送封包給kamailio,只有下面這個系統回應
ICMPv6 Destination Unreachable (Port unreachable)

功力太淺,放棄

(kamailio has put me in hell for two days. too tired now to write in English..... 
my suggestion to the ones who got the same ICMPv6 Port unreachable packet is,
"give it up, now!", this is no fun at all)