You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2020/04/24 22:25:26 UTC

[GitHub] [openwhisk-runtime-nodejs] rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript

rabbah commented on a change in pull request #160:
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r414896179



##########
File path: core/typescript37Action/Dockerfile
##########
@@ -0,0 +1,59 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+FROM golang:1.12 as builder
+RUN env CGO_ENABLED=0 go get github.com/apache/openwhisk-runtime-go/main \
+    && mv /go/bin/main /bin/proxy
+FROM node:12.1.0-stretch
+ENV TYPESCRIPT_VERSION=3.7.4
+COPY --from=builder /bin/proxy /bin/proxy
+RUN apt-get update && apt-get install -y \
+    imagemagick \
+    graphicsmagick \
+    unzip \
+    wget \
+    && rm -rf /var/lib/apt/lists/* &&\
+    mkdir -p /app/action
+RUN cd /app ;\
+  npm install -g yarn ;\
+  npm install -g typescript@${TYPESCRIPT_VERSION} ;\
+  echo '{"private":true}' >package.json ;\
+  npm install --save --no-package-lock --production \

Review comment:
       need to remove all these packages with the exception of these packages which are installed in our node runtimes:
   ```
       "openwhisk": "3.21.1",
       "redis": "2.8.0",
       "uuid": "3.3.0"
   ```

##########
File path: core/typescript37Action/lib/launcher.ts
##########
@@ -0,0 +1,101 @@
+/*
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+*/
+try {
+const main = require("./main__").main
+const readline = require('readline');
+const fs = require("fs")
+const os = require("os")
+
+function vscodeDebug() {
+  let ifaces = os.networkInterfaces()
+  for(let iface of Object.keys(ifaces)) {
+    for(let ip of ifaces[iface]) {
+      if(!ip.internal) {
+        return {
+          "type": "node",
+          "request": "attach",
+          "name": process.env["__OW_ACTION_NAME"],
+          "address": ip.address,
+          "port": 8081,
+          "localRoot": "${workspaceFolder}",
+          "remoteRoot": __dirname
+        }
+      }
+    }
+  }
+  return {"error": "cannot find external interface"}
+}
+
+async function actionLoop() {
+  const out = fs.createWriteStream(null,
+    { fd: 3, encoding: "utf8" })
+    process.stdin.setEncoding('utf8');
+  const rl = readline.createInterface({
+    input: process.stdin
+  });
+  const debugging = "__OW_DEBUG_PORT" in process.env
+  out.write(JSON.stringify({"ok":true})+"\n");
+  for await (const line of rl) {
+    try {
+      let args = JSON.parse(line)
+      let value = args.value || {}
+      for (let key in args) {
+          if(key !== "value") {
+            let envar = "__OW_"+key.toUpperCase()
+            process.env[envar] = args[key]
+          }
+      }
+      let result = {}
+      if(debugging && "debugWith" in value) {
+        if(value["debugWith"]==="vscode")
+          result = vscodeDebug()
+        else
+          result = {"error": "requested unknown debugger"}
+      } else {
+        result = main(value)
+        if(typeof result === 'undefined') {

Review comment:
       should this be `if(typeof result === undefined)` (no quotes around undefined)?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org