20190513_jeffrey - silenceuncrio/diary GitHub Wiki

0910

review

整理一下上禮拜五下班前對 fastcgi 問題的發現

搭配以下的 lighttpd.conf

server.modules              = (
#                               "mod_rewrite",
#                               "mod_redirect",
#                               "mod_alias",
                                "mod_access",
...
                                "mod_fastcgi",
...
                                "mod_accesslog" )

## a static document-root, for virtual-hosting take look at the
## server.virtual-* options
server.document-root        = "/www/"

## where to send error-messages to
server.errorlog             = "/home/log/lighttpd.error.log"

# files to check for if .../ is requested
index-file.names            = ( "index.php", "index.html",
                                "index.htm", "default.htm" )
...
#### accesslog module
accesslog.filename          = "/www/logs/access.log"
debug.log-request-handling = "enable"

...

##
# which extensions should not be handle via static-file transfer
#
# .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

...

#### fastcgi module
## read fastcgi.txt for more info
## for PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini
fastcgi.server = (
  ".fcgi" =>
  (( "host" => "127.0.0.1", 
     "port" => 1026,
      "bin-path" => "/www/fcgi-bin/iweb.fcgi" 
  )),
)
fastcgi.debug = 1

...

一下子就會產出一個很大的 log - /home/log/lighttpd.error.log

快 10 MB

一個正常的 request 會有以下的 log

-- splitting Request-URI 
Request-URI     :  /fcgi-bin/iweb.fcgi?app=sntp&act=help 
URI-scheme      :  http 
URI-authority   :  192.168.1.1 
URI-path (raw)  :  /fcgi-bin/iweb.fcgi 
URI-path (clean):  /fcgi-bin/iweb.fcgi 
URI-query       :  app=sntp&act=help 
 -- mod_access_uri_handler called 
 -- before doc_root 
 Doc-Root     : /www/ 
 Rel-Path     : /fcgi-bin/iweb.fcgi 
 Path         :  
 -- after doc_root 
 Doc-Root     : /www/ 
 Rel-Path     : /fcgi-bin/iweb.fcgi 
 Path         : /www/fcgi-bin/iweb.fcgi 
 -- logical -> physical 
 Doc-Root     : /www/ 
 Basedir      : /www/ 
 Rel-Path     : /fcgi-bin/iweb.fcgi 
 Path         : /www/fcgi-bin/iweb.fcgi 
 -- handling physical path 
 Path         : /www/fcgi-bin/iweb.fcgi 
 -- file found 
 Path         : /www/fcgi-bin/iweb.fcgi 
 -- handling subrequest 
 Path         : /www/fcgi-bin/iweb.fcgi 
 -- mod_access_uri_handler called 
 handling it in mod_fastcgi 

看一下錯誤的時候

 -- splitting Request-URI 
 Request-URI     :  /fcgi-bin/iweb.fcgi?app=sntp&act=config 
 URI-scheme      :  http 
 URI-authority   :  192.168.1.1 
 URI-path (raw)  :  /fcgi-bin/iweb.fcgi 
 URI-path (clean):  /fcgi-bin/iweb.fcgi 
 URI-query       :  app=sntp&act=config 
 -- mod_access_uri_handler called 
 -- before doc_root 
 Doc-Root     : /www/ 
 Rel-Path     : /fcgi-bin/iweb.fcgi 
 Path         :  
 -- after doc_root 
 Doc-Root     : /www/ 
 Rel-Path     : /fcgi-bin/iweb.fcgi 
 Path         : /www/fcgi-bin/iweb.fcgi 
 -- logical -> physical 
 Doc-Root     : /www/ 
 Basedir      : /www/ 
 Rel-Path     : /fcgi-bin/iweb.fcgi 
 Path         : /www/fcgi-bin/iweb.fcgi 
 -- handling physical path 
 Path         : /www/fcgi-bin/iweb.fcgi 
 -- file found 
 Path         : /www/fcgi-bin/iweb.fcgi 
 -- handling subrequest 
 Path         : /www/fcgi-bin/iweb.fcgi 
 -- mod_access_uri_handler called 
 handling it in mod_fastcgi 
 establishing connection failed: Connection refused socket: tcp:127.0.0.1:1029 
 backend disabled for 1 seconds 
 backend is overloaded; we'll disable it for 1 seconds and send the request to another backend instead: reconnects: 0 load: 2 
 child signaled: 8 
 --- fastcgi spawning \n\tsocket tcp:127.0.0.1:1029 \n\tcurrent: 1 / 4 
 new proc, socket: 1029  
 establishing connection failed: Connection refused socket: tcp:127.0.0.1:1029 
 backend disabled for 1 seconds 
 backend is overloaded; we'll disable it for 1 seconds and send the request to another backend instead: reconnects: 0 load: 1 
 got proc: pid: 12449 socket: tcp:127.0.0.1:1028 load: 1 
 got proc: pid: 12449 socket: tcp:127.0.0.1:1028 load: 2 
 released proc: pid: 12449 socket: tcp:127.0.0.1:1028 load: 1 
 unexpected end-of-file (perhaps the fastcgi process died): pid: 12449 socket: tcp:127.0.0.1:1028 
 response not received, request sent: 870 on socket: tcp:127.0.0.1:1028 for /fcgi-bin/iweb.fcgi?app=sntp&act=config, closing connection 
 released proc: pid: 12449 socket: tcp:127.0.0.1:1028 load: 0 

注意到多出來的部分

 establishing connection failed: Connection refused socket: tcp:127.0.0.1:1029 
 backend disabled for 1 seconds 
 backend is overloaded; we'll disable it for 1 seconds and send the request to another backend instead: reconnects: 0 load: 2 
 child signaled: 8 
 --- fastcgi spawning \n\tsocket tcp:127.0.0.1:1029 \n\tcurrent: 1 / 4 
 new proc, socket: 1029  
 establishing connection failed: Connection refused socket: tcp:127.0.0.1:1029 
 backend disabled for 1 seconds 
 backend is overloaded; we'll disable it for 1 seconds and send the request to another backend instead: reconnects: 0 load: 1 
 got proc: pid: 12449 socket: tcp:127.0.0.1:1028 load: 1 
 got proc: pid: 12449 socket: tcp:127.0.0.1:1028 load: 2 
 released proc: pid: 12449 socket: tcp:127.0.0.1:1028 load: 1 
 unexpected end-of-file (perhaps the fastcgi process died): pid: 12449 socket: tcp:127.0.0.1:1028 
 response not received, request sent: 870 on socket: tcp:127.0.0.1:1028 for /fcgi-bin/iweb.fcgi?app=sntp&act=config, closing connection 
 released proc: pid: 12449 socket: tcp:127.0.0.1:1028 load: 0 

目前的 log 位置 - /home/log/lighttpd.error.log 是寫到 nand flash

0945

先改成 ram 試試 - /tmp/log/lighttpd.error.log

問題還是一樣

0955

乾脆不要 log 了

問題還是一樣

1000

看來目前跟 fastcgi 沒有緣分阿

回到最後一次的 commit 再 build 一次 image

base on 該版本改回 cgi

1030

lighttpd -f /home/factory/icos/lighttpd/lighttpd.conf

chrome 敲網址 192.168.1.1 按 enter

M300 kernel crash

再拔插電重開機

發現從 M300 ping 我電腦端 ping 不通

cpu 卡再重裝一次

這次從 M300 ping 我電腦端就 ping 通了

網頁也開起來了

commit 先

ommit d92964e14b862d83407cad3b6f695c92dedbd018
Refs: [feature/lighttpd]
Author: jeffrey <[email protected]>
Date:   Mon May 13 10:47:33 2019 +0800

    give up on fastcgi soluvtion with lighttpd; use cgi solution
    - 500 - Internal Server Error
    - no time to find out the problem

 .../lighttpd/lighttpd_1.4.36.bbappend              |  1 -
 .../home/factory/icos/lighttpd/lighttpd.conf       | 34 ++++------------------
 proscend/prosrc/Makefile                           |  2 +-
 3 files changed, 6 insertions(+), 31 deletions(-)

1115

新的出發點面對的第一關

/api/whoAmI?uuid=0.xxxx

我來寫一隻 /cgi-bin/api_whoAmI.cgi

然後利用 url rewrite 把 /api/whoAmI?uuid=0.xxxx rewrite 成 /cgi-bin/api_whoAmI.cgi

1420

寫完 /cgi-bin/api_whoAmI.cgi 發現不能沒有 act 這個 parameter

再改寫成 api.cgi

commit 4b4d3e82c795c1eccf848a7d5ab4cc1550c67afd
Refs: [feature/lighttpd]
Author: jeffrey <[email protected]>
Date:   Mon May 13 14:45:06 2019 +0800

    - use url rewirte to rewrite '/api/whoAmI?uuid=0.xxxx' to '/cgi-bin/api.cgi?act=whoAmI'
    - implement '/cgi-bin/api.cgi?act=whoAmI'
      - always reply "{ "name": "guest", "level": 0 }"
    - add jweb.out.json.whoAmI()

 .../rootfs/home/factory/icos/lighttpd/lighttpd.conf        |  7 ++++++-
 proscend/prosrc/webcgi/Makefile                            |  7 +++++++
 proscend/prosrc/webcgi/jweb.c                              | 14 ++++++++++++++
 proscend/prosrc/webcgi/jweb.h                              |  1 +
 4 files changed, 28 insertions(+), 1 deletion(-)

1615

從 jweb 讀取 session 來判斷 login 的使用者

commit d5bda6a7576005e6797f87bfd77c71f7065f3012
Refs: [feature/lighttpd]
Author: jeffrey <[email protected]>
Date:   Mon May 13 16:14:03 2019 +0800

    according to the session for authorization

 proscend/prosrc/fcgi/api.c    |  7 +++++--
 proscend/prosrc/webcgi/jweb.c | 10 ++++++++++
 proscend/prosrc/webcgi/jweb.h |  6 ++++++
 3 files changed, 21 insertions(+), 2 deletions(-)

目前只要有讀到 session 就當作是 root

剛剛試了 dmz 的 apply

沒啥問題