aes67-web-monitorの構築

お久しぶりです

aes67-web-monitor
ブラウザでAES67ストリームを検聴することができるサービスです。
https://github.com/nicolassturmel/aes67-web-monitor

今回はHyper-V上にUbuntu環境を作ってみました。

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.3 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

やっぱりLTSやろ

必要なのパッケージをインストール

$ sudo apt install nodejs npm git
$ node --version
v8.10.0

もし、aes67-web-monitorが起動できない場合は、
Nodeのバージョンをあげるといいかもしれません。

$ sudo npm install n -g
$ sudo n stable
$ node --version
v12.18.4

Git cloneして、Nodeの依存関係を解決します。
この作業をrootでやるとエラーするのでユーザーで行います。

$ git clone https://github.com/nicolassturmel/aes67-web-monitor
Cloning into 'aes67-web-monitor'...
remote: Enumerating objects: 59, done.
remote: Counting objects: 100% (59/59), done.
remote: Compressing objects: 100% (41/41), done.
remote: Total 59 (delta 28), reused 44 (delta 15), pack-reused 0
Unpacking objects: 100% (59/59), done.
$
$ cd aes67-web-monitor
$ ll
total 72
drwxrwxr-x  5 neko6 neko6  4096  9月 17 12:57 ./
drwxr-xr-x 17 neko6 neko6  4096  9月 17 12:56 ../
drwxrwxr-x  8 neko6 neko6  4096  9月 17 12:56 .git/
-rw-rw-r--  1 neko6 neko6    13  9月 17 12:56 .gitignore
-rw-rw-r--  1 neko6 neko6  1536  9月 17 12:56 README.md
drwxrwxr-x  2 neko6 neko6  4096  9月 17 12:56 html/
drwxrwxr-x 61 neko6 neko6  4096  9月 17 12:58 node_modules/
-rw-rw-r--  1 neko6 neko6 15596  9月 17 12:56 package-lock.json
-rw-rw-r--  1 neko6 neko6   804  9月 17 12:56 package.json
-rw-rw-r--  1 neko6 neko6  5024  9月 17 12:56 rtp-worker.js
-rw-rw-r--  1 neko6 neko6  9570  9月 17 12:56 server.js
-rw-rw-r--  1 neko6 neko6  1222  9月 17 12:56 statistics.js
$
$ npm i
aes67-web-monitor@1.0.0 /home/neko6/aes67-web-monitor
├── UNMET PEER DEPENDENCY bufferutil@^4.0.1
├─┬ express@4.17.1
│ ├─┬ accepts@1.3.7
│ │ ├─┬ mime-types@2.1.27
│ │ │ └── mime-db@1.44.0
│ │ └── negotiator@0.6.2
│ ├── array-flatten@1.1.1
│ ├─┬ body-parser@1.19.0
│ │ ├── bytes@3.1.0
│ │ ├─┬ http-errors@1.7.2
│ │ │ ├── inherits@2.0.3
│ │ │ └── toidentifier@1.0.0
│ │ ├─┬ iconv-lite@0.4.24
│ │ │ └── safer-buffer@2.1.2
│ │ └── raw-body@2.4.0
│ ├── content-disposition@0.5.3
│ ├── content-type@1.0.4
│ ├── cookie@0.4.0
│ ├── cookie-signature@1.0.6
│ ├─┬ debug@2.6.9
│ │ └── ms@2.0.0
│ ├── depd@1.1.2
│ ├── encodeurl@1.0.2
│ ├── escape-html@1.0.3
│ ├── etag@1.8.1
│ ├─┬ finalhandler@1.1.2
│ │ └── unpipe@1.0.0
│ ├── fresh@0.5.2
│ ├── merge-descriptors@1.0.1
│ ├── methods@1.1.2
│ ├─┬ on-finished@2.3.0
│ │ └── ee-first@1.1.1
│ ├── parseurl@1.3.3
│ ├── path-to-regexp@0.1.7
│ ├─┬ proxy-addr@2.0.6
│ │ ├── forwarded@0.1.2
│ │ └── ipaddr.js@1.9.1
│ ├── qs@6.7.0
│ ├── range-parser@1.2.1
│ ├── safe-buffer@5.1.2
│ ├─┬ send@0.17.1
│ │ ├── destroy@1.0.4
│ │ ├── mime@1.6.0
│ │ └── ms@2.1.1
│ ├── serve-static@1.14.1
│ ├── setprototypeof@1.1.1
│ ├── statuses@1.5.0
│ ├─┬ type-is@1.6.18
│ │ └── media-typer@0.3.0
│ ├── utils-merge@1.0.1
│ └── vary@1.1.2
├── sdp-transform@2.14.0
├─┬ url@0.11.0
│ ├── punycode@1.3.2
│ └── querystring@0.2.0
├── UNMET PEER DEPENDENCY utf-8-validate@^5.0.2
├── vhost@3.0.2
└── ws@7.3.1

npm WARN ws@7.3.1 requires a peer of bufferutil@^4.0.1 but none was installed.
npm WARN ws@7.3.1 requires a peer of utf-8-validate@^5.0.2 but none was installed.

どうやら足りないものがあるようなので追加インストールします。

$ npm install bufferutil utf-8-validate
> bufferutil@4.0.1 install /home/neko6/aes67-web-monitor/node_modules/bufferutil
> node-gyp-build

> utf-8-validate@5.0.2 install /home/neko6/aes67-web-monitor/node_modules/utf-8-validate
> node-gyp-build

aes67-web-monitor@1.0.0 /home/neko6/aes67-web-monitor
├── bufferutil@4.0.1  extraneous
└── utf-8-validate@5.0.2  extraneous

これで準備はできました。

さて起動してみます。
rootで起動しないとエラーこきますので注意。

$ sudo node --experimental-worker server.js
[
  { name: 'lo', ip: '127.0.0.1', mask: '255.0.0.0' },
  { name: 'eth0', ip: '10.255.1.11', mask: '255.255.255.0' }
]
Server ready...
Server ready...
Server started on port 8067 :)
One more worker
undefined
Socket connected. sending data...
Socket connected. sending data...
{"type":"selectInterface","data":"10.255.1.11"} { type: 'selectInterface', data: '10.255.1.11' }
UDP Client listening on 224.0.1.129:319
UDP Client listening on 239.255.255.255:9875

あとはブラウザから
http://サーバIP:8067
へアクセスすると、SAPやAES67ストリームが流れて来ていると検聴できると思います。
(そこまで環境が作れなかったw)

INITスクリプト
「dir=””」には置いてあるディレクトリを指定してください

#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

dir=""
cmd="node --experimental-worker server.js"
#user=""

name=`basename $0`
pid_file="/var/run/$name.pid"
stdout_log="/var/log/$name.log"
stderr_log="/var/log/$name.err"

get_pid() {
    cat "$pid_file"
}

is_running() {
    [ -f "$pid_file" ] && ps -p `get_pid` > /dev/null 2>&1
}

case "$1" in
    start)
    if is_running; then
        echo "Already started"
    else
        echo "Starting $name"
        cd "$dir"
        if [ -z "$user" ]; then
            sudo $cmd >> "$stdout_log" 2>> "$stderr_log" &
        else
            sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
        fi
        echo $! > "$pid_file"
        if ! is_running; then
            echo "Unable to start, see $stdout_log and $stderr_log"
            exit 1
        fi
    fi
    ;;
    stop)
    if is_running; then
        echo -n "Stopping $name.."
        kill `get_pid`
        for i in 1 2 3 4 5 6 7 8 9 10
        # for i in `seq 10`
        do
            if ! is_running; then
                break
            fi

            echo -n "."
            sleep 1
        done
        echo

        if is_running; then
            echo "Not stopped; may still be shutting down or shutdown may have failed"
            exit 1
        else
            echo "Stopped"
            if [ -f "$pid_file" ]; then
                rm "$pid_file"
            fi
        fi
    else
        echo "Not running"
    fi
    ;;
    restart)
    $0 stop
    if is_running; then
        echo "Unable to stop, will not attempt to start"
        exit 1
    fi
    $0 start
    ;;
    status)
    if is_running; then
        echo "Running"
    else
        echo "Stopped"
        exit 1
    fi
    ;;
    *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
    ;;
esac

exit 0

あとは使えるかのチェックしてから

# update-rc.d aes67-web-monitor defaults

これで良いはず・・・

もし以下のようなエラーが出た場合、
Node自体のバージョンが古いため、アップデートしてください(6系以上じゃないとだめかも)

# npm install bufferutil utf-8-validate

> bufferutil@4.0.1 install /home/neko6/aes67-web-monitor/node_modules/bufferutil
> node-gyp-build

make: Entering directory '/home/neko6/aes67-web-monitor/node_modules/bufferutil/build'
  CC(target) Release/obj.target/bufferutil/src/bufferutil.o
../src/bufferutil.c:3:22: fatal error: node_api.h: No such file or directory
compilation terminated.
bufferutil.target.mk:88: recipe for target 'Release/obj.target/bufferutil/src/bufferutil.o' failed
make: *** [Release/obj.target/bufferutil/src/bufferutil.o] Error 1
make: Leaving directory '/home/neko6/aes67-web-monitor/node_modules/bufferutil/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:269:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.14.111
gyp ERR! command "/usr/bin/nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/neko6/aes67-web-monitor/node_modules/bufferutil
gyp ERR! node -v v4.2.6
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
aes67-web-monitor@1.0.0 /opt/aes67-web-monitor
├── UNMET PEER DEPENDENCY bufferutil@^4.0.1
└── utf-8-validate@5.0.2  extraneous

npm ERR! Linux 4.14.111
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "bufferutil" "utf-8-validate"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE

npm ERR! bufferutil@4.0.1 install: `node-gyp-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bufferutil@4.0.1 install script 'node-gyp-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bufferutil package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs bufferutil
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls bufferutil
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/neko6/aes67-web-monitor/npm-debug.log

また、
「git clone」から「npm install bufferutil utf-8-validate」まで
の作業をrootでやると以下のようなエラーを吐くので注意。

npm ERR! Linux 5.8.13-sunxi
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "bufferutil" "utf-8-validate"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE

npm ERR! bufferutil@4.0.1 install: `node-gyp-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bufferutil@4.0.1 install script 'node-gyp-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bufferutil package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs bufferutil
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls bufferutil
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /opt/aes67-web-monitor/npm-debug.log

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

Enter code * Time limit is exhausted. Please reload CAPTCHA.

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください