20190424_jeffrey - silenceuncrio/diary GitHub Wiki

0900

先回一下 yuncore 的 zmk 的問題

0925

試著在 M300 上 run fast cgi

OpenEmbedded 有現成的 recipe

目前 M300 上這兩個 recipe 都有

sources/meta-openembedded/meta-webserver/recipes-support/fcgi/fcgi_2.4.0.bb

DESCRIPTION = "FastCGI is a protocol for interfacing interactive programs with a web server."
HOMEPAGE = "http://www.fastcgi.com"
LICENSE = "OML"
LIC_FILES_CHKSUM = "file://LICENSE.TERMS;md5=e3aacac3a647af6e7e31f181cda0a06a"

SRC_URI = "http://fossies.org/linux/www/${BP}.tar.gz \
           file://Fix_EOF_not_declared_issue.patch \
           file://add_foreign_to_AM_INIT_AUTOMAKE.patch \
"
SRC_URI[md5sum] = "d15060a813b91383a9f3c66faf84867e"
SRC_URI[sha256sum] = "66fc45c6b36a21bf2fbbb68e90f780cc21a9da1fffbae75e76d2b4402d3f05b9"

inherit autotools

PARALLEL_MAKE = ""

sources/meta-openembedded/meta-webserver/recipes-support/spawn-fcgi/spawn-fcgi_1.6.4.bb

SUMMARRY = "spawn-fcgi is used to spawn FastCGI applications"
HOMEPAGE = "http://redmine.lighttpd.net/projects/spawn-fcgi"

LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://COPYING;md5=e4dac5c6ab169aa212feb5028853a579"

SRC_URI = "http://download.lighttpd.net/spawn-fcgi/releases-1.6.x/spawn-fcgi-${PV}.tar.gz \
           file://fix_configure_ipv6_test.patch"

SRC_URI[md5sum] = "e970de4efe8045c01dd76280f39901aa"
SRC_URI[sha256sum] = "ab327462cb99894a3699f874425a421d934f957cb24221f00bb888108d9dd09e"

inherit autotools

PACKAGECONFIG ??= "${@bb.utils.contains("DISTRO_FEATURES", "ipv6", "ipv6", "", d)}"
PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,"

從 recipe bb file 的描述來看

  • fcgi_2.4.0.bb
    • FastCGI is a protocol for interfacing interactive programs with a web server.
  • spawn-fcgi
    • spawn-fcgi is used to spawn FastCGI applications

我應該兩個 recipe 都需要

注意到 /sources/meta-openembedded/meta-webserver 並沒被加到 bblayers

這要修改 conf/bblayers.conf 不然該目錄下的 recipe 都不會被找到

修改如下

diff --git a/conf/bblayers.conf b/conf/bblayers.conf
index eb379d9..b3b5048 100644
--- a/conf/bblayers.conf
+++ b/conf/bblayers.conf
@@ -25,4 +25,5 @@ BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-python "
 BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-ruby "
 BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-filesystems "
 BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-gnome "
+BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-webserver "
 BBLAYERS += " ${BSPDIR}/meta-proscend "
diff --git a/meta-proscend/recipes-core/prosrc/prosrc_0.1.bb b/meta-proscend/recipes-core/prosrc/prosrc_0.1.bb
index 095fd09..7791df4 100644
--- a/meta-proscend/recipes-core/prosrc/prosrc_0.1.bb
+++ b/meta-proscend/recipes-core/prosrc/prosrc_0.1.bb
@@ -91,6 +91,9 @@ RDEPENDS_${PN} += " conntrack-tools"
 # lighttpd
 RDEPENDS_${PN} += " lighttpd"

+# fcgi spawn-fcgi
+RDEPENDS_${PN} += " fcgi spawn-fcgi"
+
 # ======================================

 # Build dependence

build image

1115

mfgtools 燒錄後開機試試

fcgi 提供的是 library 與 header file 讓我們寫的 c code 能 include

library 如下

root@Cellular Router:/usr/lib# ls libfcg* -al
lrwxrwxrwx    1 root     root            18 Jan  1  1970 libfcgi++.so.0 -> libfcgi++.so.0.0.0
-rwxr-xr-x    1 root     root         12240 Apr 24 02:49 libfcgi++.so.0.0.0
lrwxrwxrwx    1 root     root            16 Jan  1  1970 libfcgi.so.0 -> libfcgi.so.0.0.0
-rwxr-xr-x    1 root     root         32312 Apr 24 02:49 libfcgi.so.0.0.0
root@Cellular Router:/usr/lib#

header files 不知道在哪裡

spawn-fcgi 是個執行檔 說明如下

root@Cellular Router:~# spawn-fcgi -h
Usage: spawn-fcgi [options] [-- <fcgiapp> [fcgi app arguments]]

spawn-fcgi v1.6.4 (ipv6) - spawns FastCGI processes

Options:
 -f <path>      filename of the fcgi-application (deprecated; ignored if
                <fcgiapp> is given; needs /bin/sh)
 -d <directory> chdir to directory before spawning
 -a <address>   bind to IPv4/IPv6 address (defaults to 0.0.0.0)
 -p <port>      bind to TCP-port
 -s <path>      bind to Unix domain socket
 -M <mode>      change Unix domain socket mode (octal integer, default: allow
                read+write for user and group as far as umask allows it)
 -C <children>  (PHP only) numbers of childs to spawn (default: not setting
                the PHP_FCGI_CHILDREN environment variable - PHP defaults to 0)
 -F <children>  number of children to fork (default 1)
 -b <backlog>   backlog to allow on the socket (default 1024)
 -P <path>      name of PID-file for spawned process (ignored in no-fork mode)
 -n             no fork (for daemontools)
 -v             show version
 -?, -h         show this help
(root only)
 -c <directory> chroot to directory
 -S             create socket before chroot() (default is to create the socket
                in the chroot)
 -u <user>      change to user-id
 -g <group>     change to group-id (default: primary group of user if -u
                is given)
 -U <user>      change Unix domain socket owner to user-id
 -G <group>     change Unix domain socket group to group-id

1300

參考僅存的半官方網站 FastCGI.com Archives

這邊有 FastCGI Programmer’ Guide

耐著性子看一下吧

1530

先試著 build 出第一個範例 - TinyFastCGI

#include "fcgi_stdio.h" /* fcgi library; put it first*/

#include <stdlib.h>

int count;

void initialize(void)
{
  count=0;
}

void main(void)
{
/* Initialization. */  
  initialize();

/* Response loop. */
  while (FCGI_Accept() >= 0)   {
    printf("Content-type: text/html\r\n"
           "\r\n"
           "<title>FastCGI Hello! (C, fcgi_stdio library)</title>"
           "<h1>FastCGI Hello! (C, fcgi_stdio library)</h1>"
           "Request number %d running on host <i>%s</i>\n",
            ++count, getenv("SERVER_HOSTNAME"));
  }
}
⚠️ **GitHub.com Fallback** ⚠️