serverless-php icon indicating copy to clipboard operation
serverless-php copied to clipboard

Is the new PHP file working?

Open san-kumar opened this issue 8 years ago • 3 comments

I'm trying to deploy with the latest version and I'm getting this error

Serverless: Invoke invoke
{
    "errorMessage": "Process error code 1: ",
    "errorType": "Error",
    "stackTrace": [
        "ChildProcess.<anonymous> (/var/task/handler.js:47:23)",
        "emitTwo (events.js:106:13)",
        "ChildProcess.emit (events.js:191:7)",
        "maybeClose (internal/child_process.js:886:16)",
        "Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)"
    ]
}

  Error --------------------------------------------------

  Invoked function failed

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Stack Trace --------------------------------------------

This is a fresh install (no modifications).

Anybody else facing this problem with the latest version? Is this because of the new PHP file (earlier it was working fine).

san-kumar avatar Dec 25 '17 23:12 san-kumar

Hi @san-kumar I've just rerun through the steps in the README and its working fine, although there is one more step you need to do to get it working, which #3 was opened to attempt to address (albeit not very clearly!)

For one reason or another, serverless install doesn't seem to play nice with git lfs and as such the PHP binary doesn't actually download properly. To work around this, after doing serverless install you need to rebuild the PHP binary:

sh buildphp.sh

This does need docker installed, though.

Another option is to clone the repository directly from GitHub instead of using serverless. As long as you have git lfs installed it will download the PHP binary properly.

The final option is to use a combination of the two - use serverless install as directed and then simply download the PHP binary from GitHub.

I'll get on with addressing #3 to avoid others suffering with similar problems in the future!

If the above doesn't work, please provide a little more information on the steps you've run and I'll try to help debug.

araines avatar Dec 26 '17 15:12 araines

Hi Andy,

Thanks for the reply. I'm using Windows 10 so maybe that is causing the problem. I did everythinga as per the readme and then downloaded the php binary directly from github. It still won't work. Anyway, here are the steps I did:

C:\tmp\2\>serverless install --url https://github.com/araines/serverless-php

C:\tmp\2\serverless-php>wget -O php https://media.githubusercontent.com/media/araines/serverless-php/master/php

C:\tmp\2\serverless-php>sls deploy

C:\tmp\2\serverless-php>serverless invoke -f hello
{
    "errorMessage": "RequestId: 55e45e30-eafb-11e7-b724-b19b0d130fcb Process exited before completing request"
}

  Error --------------------------------------------------

  Invoked function failed

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Forums:        forum.serverless.com
     Chat:          gitter.im/serverless/serverless

  Your Environment Information -----------------------------
     OS:                     win32
     Node Version:           8.9.1
     Serverless Version:     1.25.0

Attached is the Cloudwatch log (if it is of any help) cloudwatch-log.txt

san-kumar avatar Dec 27 '17 11:12 san-kumar

Oh thats really interesting - I'm a little surprised you're having problems on the Lambda environment itself - thats the bit which I'd expect to be unaffected by your local operating system!

However, I'm wondering if its do to with executable flags on the PHP binary. Looking at the Cloudwatch logs, it looks like spawn EACCES is the error being thrown - which I believe is thrown when its not able to execute a binary.

I'm afraid I'm not anything close to a Windows expert - for macOS/linux I'd do something like this to the PHP binary before doing sls deploy again:

chmod a+x php

I wonder if there is some form of equivalent for Windows?

araines avatar Dec 27 '17 12:12 araines