Email:[email protected]NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default virtualbox Running tcp://192.168.99.101:2376 v1.10.3
export DOCKER_TLS_VERIFY="
1"
export DOCKER_HOST="
tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="
C:\Users\slim1.docker\machine\machines\default"
export DOCKER_MACHINE_NAME="
default"
Run this command to configure your shell:
eval $("
C:\Program Files\Docker Toolbox\docker-machine.exe"
env default)
$
eval $("
C:\Program Files\Docker Toolbox\docker-machine.exe"
env default)NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v1.10.3
$ python --
version
Python 2.7.11
$ pip --
version
pip 8.1.2
https://git-for-windows.github.io/
https://github.com/cloudfoundry/cli/releases
https://nodejs.org/en/#download
--
upgrade https://new-console.ng.bluemix.net/openwhisk/cli/download--
apihost openwhisk.ng.bluemix.net –auth xxxxxxxxxx –namespace “xxxxxxxxxxxxxxxxxxx”ok: whisk auth set
ok: whisk API host set
ok: namespace set to [email protected]_test
--
blocking --
result{
"message": "hello"
}
ok: updated action goodbye-sir
/[email protected]_test/goodbye-sir private
--
blocking goodbye-sir ok: invoked goodbye-sir with id 4e8f1905956844f7b752ca8881e8e0ca
response:
{
"activationId": "4e8f1905956844f7b752ca8881e8e0ca",
"annotations": [],
"end": 1463117951512,
"logs": [],
"name": "goodbye-sir",
"namespace": "[email protected]",
"publish": false,
"response": {
"result": {
"payload": "I am pretty busy and can't talk right now. Goodbye, sir!"
},
"status": "success",
"success": true
},
"start": 1463117951056,
"subject": "[email protected]",
"version": "0.0.3"
}
ok: invoked goodbye-sir with id 606ddab9022041d99e8dcc8c43f66702
以下指令將印出 Action 執行結果
{
"payload": "I am pretty busy and can't talk right now. Goodbye, sir!"
}
--
blocking goodbye-sir --
param name Alex (附帶參數) "result": {
"payload": "I am pretty busy and can't talk right now. Goodbye, Alex!"
},
--
docker example hello-world (建立 hello-world container action ) ok: created action example
--
blocking --
result example error: {
"error": "the action did not produce a valid JSON response"
},
以上error,是因為 OpenWhisk 以 stdin, stdout 與 container 溝通
其格式為JSON ,如果輸出不是 JSON 格式會導致錯誤,所以會顯示錯誤:
Server 資料夾: Node.js 用來與 Openwhisk 交談
Client 資料夾: C 語言程式 example.c 作為回應 event 使用
REPOSITORY TAG IMAGE ID CREATED SIZE
chenlin2/openwhisk latest 75f52d13625f About a minute ago 435.1 MB
ubuntu 14.04 90d5884b1ee0 9 days ago 188 MB
container 啟動包含 2 部分,等待接受 http request 並執行 example.c
Starting a blackbox service
CONTAINER ID IMAGE COMMAND REATED STATUS PORTS NAMES
a155fa55a29c chenlin2/openwhisk "/bin/bash -c 'cd bla" 6 minutes ago 8080/tcp stupefied_varahamihira
eth0 Link encap:Ethernet HWaddr 02:42:ac:11:00:02 inet addr:172.17.0.2 Bcast:0.0.0.0
"
Content-Type: application/json"
-d '
{"
value"
:{"
YOUR"
:"
PAYLOAD"
}}'
172.17.0.2:8080/run {"result":{"msg":"Hello undefined from arbitrary C program!\n"}}
Login Succeeded
將 chenlin2/openwhisk images上傳至 docker hub
--
docker ACTION chenlin2/openwhisk
(建立 container action ACTION) ok: updated action ACTION
/[email protected]_test/ACTION private
payload =參數名稱, slimchen =參數值
{
"result": {
"msg": "Hello slimchen from arbitrary C program!\n"
}
}
(https://new-console.ng.bluemix.net/openwhisk/dashboard)
msg.payload = {
"name":"Alex"
};
return msg;
Namespace: 根據步驟 4 取得
Action : goodbye-sir
triggers
/[email protected]_test/goodbye-sir-trigger private
actions
/[email protected]_test/goodbye-sir private
--
enable myRule goodbye-sir-trigger goodbye-sir--
param name “ruby”--
limit 1 goodbye-sir (檢視最近一次 goodbye-sir Action id) activations
fe83bb0d314b490c8f8789fbb93761fe goodbye-sir
{
"payload": "I am pretty busy and can't talk right now. Goodbye, ruby!"
}
msg.payload = {
"name":"rubychen"
};
return msg;
Namespace: 根據步驟 4
--
limit 1 goodbye-sir (顯示最後一次啟動的 action id) activations
1b4bcee1ae1044139317810e7c321bfd goodbye-sir
{
"payload": "I am pretty busy and can't talk right now. Goodbye, rubychen!"
}
http://www.ithome.com.tw/review/104198
http://blog.altoros.com/how-to-use-openwhisk-docker-actions-in-ibm-bluemix.html
http://blog.altoros.com/bluemix-openwhisk-101-developing-a-microservice.html
http://blog.altoros.com/introduction-to-ibm-bluemix-openwhisk.html
https://new-console.ng.bluemix.net/openwhisk/
http://www.infoq.com/cn/news/2016/05/bluemix-ibm-interconnect
https://dzone.com/articles/how-to-write-javascript-actions-for-openwhisk-on-b
https://new-console.ng.bluemix.net/docs/openwhisk/openwhisk_packages.html#openwhisk_packages_trigger
https://amanoblog.wordpress.com/2016/03/03/ibm-bluemix-openwhisk-rest-api/
http://www.slideshare.net/HsuanJuLin/bluemixopenwhisk
http://blog.altoros.com/bluemix-openwhisk-101-developing-a-microservice.html
http://ryanjbaxter.com/cloud/bluemix/2016/03/24/running-whisk-actions-from-node-red.html
http://www.stevenatkin.com/index.php/2016/03/25/call-openwhisk-actions-node-red/
https://console.ng.bluemix.net/docs/openwhisk/openwhisk_triggers_rules.html
https://github.com/openwhisk/openwhisk/blob/master/docs/packages.md
https://read01.com/gRddP.html