alibaba / funcraft

(have) Fun with Serverless(API Gateway & Function Compute)
MIT License
941 stars 129 forks source link

funcraft不支持jfinal框架 #1128

Open litongjava opened 3 years ago

litongjava commented 3 years ago

funcraft的版本是3.6.23 jfinal是一款国产的java web框架

https://jfinal.com/doc
https://gitee.com/jfinal/jfinal

我创建了一个jfinal项目,代码地址

https://gitee.com/litongjava_admin/java-aliyun-fc-study/tree/master/jfinal-demo

template.yml内容如下

ROSTemplateFormatVersion: '2015-09-01'
Transform: 'Aliyun::Serverless-2018-04-03'
Resources:
  jfinal-demo: # service name
    Type: 'Aliyun::Serverless::Service'
    Properties:
      Description: This is FC service
    jfinal-demo: # function name
      Type: 'Aliyun::Serverless::Function'
      Properties:
        Handler: index.handler
        Runtime: custom
        CodeUri: ./
        MemorySize: 1024
        InstanceConcurrency: 5
        Timeout: 120

      Events:
        httpTrigger:
          Type: HTTP
          Properties:
            AuthType: ANONYMOUS
            Methods: ['GET', 'POST', 'PUT']
  Domain:
    Type: Aliyun::Serverless::CustomDomain
    Properties:
      DomainName: Auto
      Protocol: HTTP
      RouteConfig:
        Routes:
          "/*":
            ServiceName: jfinal-demo
            FunctionName: jfinal-demo

在本地启动项目

mvn clean package
java -jar jfinal-demo.jar

启动日志如下

Starting JFinal 4.9.13 -> http://0.0.0.0:80
Info: jfinal-undertow 2.5, undertow 2.0.34.Final, jvm 1.8.0_121
六月 27, 2021 7:27:32 下午 io.undertow.Undertow start
INFO: starting server: Undertow - 2.0.34.Final
六月 27, 2021 7:27:32 下午 org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
六月 27, 2021 7:27:32 下午 org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
Starting Complete in 0.7 seconds. Welcome To The JFinal World (^_^)

我为添加了2个http接口,访问一下,都访问成功 image image 发布项目到阿里云,提示发布成功

E:\dev_workspace\java\java-study\java-aliyun-fc-study\jfinal-demo>fun deploy -y
using template: template.yml
using region: cn-shanghai
using accountId: ***********4149
using accessKeyId: ***********9Wqn
using timeout: 10

Collecting your services information, in order to caculate devlopment changes...

Resources Changes(Beta version! Only FC resources changes will be displayed):

┌─────────────┬──────────────────────────────┬────────┬─────────────────────┐
│ Resource    │ ResourceType                 │ Action │ Property            │
├─────────────┼──────────────────────────────┼────────┼─────────────────────┤
│ jfinal-demo │ Aliyun::Serverless::Service  │ Add    │ Description         │
├─────────────┼──────────────────────────────┼────────┼─────────────────────┤
│             │                              │        │ Handler             │
│             │                              │        ├─────────────────────┤
│             │                              │        │ Runtime             │
│             │                              │        ├─────────────────────┤
│             │                              │        │ CodeUri             │
│ jfinal-demo │ Aliyun::Serverless::Function │ Add    ├─────────────────────┤
│             │                              │        │ MemorySize          │
│             │                              │        ├─────────────────────┤
│             │                              │        │ InstanceConcurrency │
│             │                              │        ├─────────────────────┤
│             │                              │        │ Timeout             │
├─────────────┼──────────────────────────────┼────────┼─────────────────────┤
│             │                              │        │ AuthType            │
│ httpTrigger │ HTTP                         │ Add    ├─────────────────────┤
│             │                              │        │ Methods             │
└─────────────┴──────────────────────────────┴────────┴─────────────────────┘

Waiting for service jfinal-demo to be deployed...
        Waiting for function jfinal-demo to be deployed...
                Waiting for packaging function jfinal-demo code...
                The function jfinal-demo has been packaged. A total of 22 files were compressed and the final size was 3.86 MB
                Waiting for HTTP trigger httpTrigger to be deployed...
                triggerName: httpTrigger
                methods: [ 'GET', 'POST', 'PUT' ]
                trigger httpTrigger deploy success
        function jfinal-demo deploy success
service jfinal-demo deploy success

Detect 'DomainName:Auto' of custom domain 'Domain'
Request a new temporary domain ...
The assigned temporary domain is http://54793386-1709155087484149.test.functioncompute.com,expired at 2021-07-07 19:29:46, limited by 1000 per day.
Waiting for custom domain Domain to be deployed...
custom domain Domain deploy success

使用自定义域名 http://54793386-1709155087484149.test.functioncompute.com 访问时出现下面的错误 image 后来我添加了bootstrap文件,文件内容如下

java -jar jfinal-demo.jar

重新发布并访问,出现测错误如下 image

"ErrorMessage": "The CA process either cannot be started or exited:ContainerStartDuration:35032851796. CA process cannot be started or exited already: The first line of the bootstrap script must be '#!/bin/bash',rpc error: code = 106 desc = ContainerStartDuration:35000000000. Ping CA failed due to: dial tcp 21.0.3.1:9000: i/o timeout Logs : 2021-06-27T11:42:11.002054558Z panic: standard_init_linux.go:178: exec user process caused \"exec format error\" [recovered]\r\n2021-06-27T11:42:11.002243773Z \tpanic: standard_init_linux.go:178: exec user process caused \"exec format error\"\r\n2021-06-27T11:42:11.002252264Z \r\n2021-06-27T11:42:11.002325558Z goroutine 1 [running, locked to thread]:\r\n2021-06-27T11:42:11.002359402Z panic(0x88fa80, 0xc820170c40)\r\n2021-06-27T11:42:11.002404708Z \t/usr/local/go/src/runtime/panic.go:481 +0x3e6\r\n2021-06-27T11:42:11.002437140Z github.com/urfave/cli.HandleAction.func1(0xc8200f32e8)\r\n2021-06-27T11:42:11.002468344Z \t/tmp/tmp.nD00MeOB4U/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/urfave/cli/app.go:478 +0x38e\r\n2021-06-27T11:42:11.002475774Z panic(0x88fa80, 0xc820170c40)\r\n2021-06-27T11:42:11.002479465Z \t/usr/local/go/src/runtime/panic.go:443 +0x4e9\r\n2021-06-27T11:42:11.002484269Z github.com/opencontainers/runc/libcontainer.(*LinuxFactory).StartInitialization.func1(0xc8200f2bf8, 0xc82001a0c8, 0xc8200f2d08)\r\n2021-06-27T11:42:11.002491481Z \t/tmp/tmp.nD00MeOB4U/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/factory_linux.go:259 +0x136\r\n2021-06-27T11:42:11.002495963Z github.com/opencontainers/runc/libcontainer.(*LinuxFactory).StartInitialization(0xc820059630, 0x7f0d64b25728, 0xc820170c40)\r\n2021-06-27T11:42:11.002503642Z \t/tmp/tmp.nD00MeOB4U/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/factory_linux.go:277 +0x5b1\r\n2021-06-27T11:42:11.002508012Z main.glob.func8(0xc820076a00, 0x0, 0x0)\r\n2021-06-27T11:42:11.002512709Z \t/tmp/tmp.nD00MeOB4U/src/github.com/opencontainers/runc/main_unix.go:26 +0x68\r\n2021-06-27T11:42:11.002517491Z reflect.Value.call(0x7f4760, 0x9a4fa8, 0x13, 0x8ebca8, 0x4, 0xc8200f3268, 0x1, 0x1, 0x0, 0x0, ...)\r\n2021-06-27T11:42:11.002521747Z \t/usr/local/go/src/reflect/value.go:435 +0x120d\r\n2021-06-27T11:42:11.002525631Z reflect.Value.Call(0x7f4760, 0x9a4fa8, 0x13, 0xc8200f3268, 0x1, 0x1, 0x0, 0x0, 0x0)\r\n2021-06-27T11:42:11.002535435Z \t/usr/local/go/src/reflect/value.go:303 +0xb1\r\n2021-06-27T11:42:11.002539011Z github.com/urfave/cli.HandleAction(0x7f4760, 0x9a4fa8, 0xc820076a00, 0x0, 0x0)\r\n2021-06-27T11:42:11.002543038Z \t/tmp/tmp.nD00MeOB4U/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/urfave/cli/app.go:487 +0x2ee\r\n2021-06-27T11:42:11.002546984Z github.com/urfave/cli.Command.Run(0x8eeb50, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x984460, 0x51, 0x0, ...)\r\n2021-06-27T11:42:11.002550828Z \t/tmp/tmp.nD00MeOB4U/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/urfave/cli/command.go:191 +0xfec\r\n2021-06-27T11:42:11.002554856Z github.com/urfave/cli.(*App).Run(0xc820001800, 0xc82000a100, 0x2, 0x2, 0x0, 0x0)\r\n2021-06-27T11:42:11.002737547Z \t/tmp/tmp.nD00MeOB4U/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/urfave/cli/app.go:240 +0xaa4\r\n2021-06-27T11:42:11.002746848Z main.main()\r\n2021-06-27T11:42:11.002761404Z \t/tmp/tmp.nD00MeOB4U/src/github.com/opencontainers/runc/main.go:137 +0xe24\r\n"