Failed to install Delve for the lambda container on Mac - amazon-web-services

I used the VS Code AWS Toolkit and SAM to create a basic SAM web app based on Go(I VS Code generate it).
It's some generic template code for the Lambda that reads IP from request and returns a Hello <IP> on the browser.
My end goal is to manage to see line by line debugging on my lambda function in VS Code.
There seem to be some default configurations in my launch.json:
{
"configurations": [
{
"type": "aws-sam",
"request": "direct-invoke",
"name": "sunflowers:HelloWorldFunction (go1.x)",
"invokeTarget": {
"target": "template",
"templatePath": "${workspaceFolder}/sunflowers/template.yaml",
"logicalId": "HelloWorldFunction"
},
"lambda": {
"payload": {},
"environmentVariables": {},
"runtime": "go1.x"
}
},
{
"type": "aws-sam",
"request": "direct-invoke",
"name": "API sunflowers:HelloWorldFunction (go1.x)",
"invokeTarget": {
"target": "api",
"templatePath": "${workspaceFolder}/sunflowers/template.yaml",
"logicalId": "HelloWorldFunction"
},
"api": {
"path": "/hello",
"httpMethod": "GET",
"payload": {
"json": {}
}
},
"lambda": {
"runtime": "go1.x"
}
}
]
}
However on clicking the "Start Debugging" button, I get that error that it can't install delve:
2022-08-03 21:20:46 [ERROR]: log level: info
2022-08-03 21:20:47 [INFO]: Retrieving AWS endpoint data
2022-08-03 21:20:47 [INFO]: OS: Darwin arm64 21.6.0
2022-08-03 21:20:47 [INFO]: Visual Studio Code extension host: 1.69.2
2022-08-03 21:20:47 [INFO]: AWS Toolkit: 1.46.0
2022-08-03 21:20:47 [INFO]: node: 16.13.2
2022-08-03 21:20:47 [INFO]: electron: 18.3.5
2022-08-03 21:21:49 [WARN]: SAM debug: missing AWS credentials (Toolkit is not connected)
2022-08-03 21:21:50 [INFO]: autoconnect: connected: 'profile:default'
2022-08-03 21:21:50 [INFO]: Command: (not started) [/Users/varungawande/Library/Application Support/Code/User/globalStorage/amazonwebservices.aws-toolkit-vscode/debuggers/delve/install-1.9.0.sh ]
2022-08-03 21:21:50 [ERROR]: Failed to cross-compile Delve debugger: Error: spawn Unknown system error -8
at ChildProcess.spawn (node:internal/child_process:412:11)
at Object.spawn (node:child_process:718:9)
at Function.l [as spawn] (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:27:9212)
at /Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:1734:1495
at new Promise (<anonymous>)
at cc.run (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:1734:1099)
at AH (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2076:252)
at _H (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2075:195)
at E6.invokeConfig (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:5965)
at E6.makeAndInvokeConfig (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:1314)
at E6.resolveDebugConfigurationWithSubstitutedVariables (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:1202) {
errno: -8,
code: 'Unknown system error -8',
syscall: 'spawn'
}
2022-08-03 21:22:27 [INFO]: Command: (not started) [/Users/varungawande/Library/Application Support/Code/User/globalStorage/amazonwebservices.aws-toolkit-vscode/debuggers/delve/install-1.9.0.sh ]
2022-08-03 21:22:27 [ERROR]: Failed to cross-compile Delve debugger: Error: spawn Unknown system error -8
at ChildProcess.spawn (node:internal/child_process:412:11)
at Object.spawn (node:child_process:718:9)
at Function.l [as spawn] (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:27:9212)
at /Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:1734:1495
at new Promise (<anonymous>)
at cc.run (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:1734:1099)
at AH (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2076:252)
at _H (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2075:195)
at E6.invokeConfig (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:5965)
at E6.makeAndInvokeConfig (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:1314)
at E6.resolveDebugConfigurationWithSubstitutedVariables (/Users/varungawande/.vscode/extensions/amazonwebservices.aws-toolkit-vscode-1.46.0/dist/src/main.js:2082:1202) {
errno: -8,
code: 'Unknown system error -8',
syscall: 'spawn'
}
2022-08-03 21:25:49 [INFO]: telemetry: sent batch (size=5)
My lambda requires the architecture amd64, while my Mac has the M1 chip, so it has an architecture of arm64. Is the above error due to this architecture mismatch?
I tried running the lambda locally using docker and that worked(using sam local start-api and sam local invoke), but am not sure the above with work as smoothly when using a debugger.

Turns out this is due to a bug in AWS Toolkit extension of VS Code. It was fixed in AWS Toolkit 1.47.

Related

Could not launch AWS SAM application when using VS Code Debugger "Function not implemented"

I have a generic SAM application generated by AWS Toolkit.
My end goal is to debug my go application line by line.
Sorry if this question gets too long, but I have tried my best to add as few relevant details as possible, while trying to make sure I don't miss anything important.
I am using the default launch.json configurations generated by the Toolkit:
{
"configurations": [
{
"type": "aws-sam",
"request": "direct-invoke",
"name": "sunflowers:HelloWorldFunction (go1.x)",
"invokeTarget": {
"target": "template",
"templatePath": "${workspaceFolder}/template.yaml",
"logicalId": "HelloWorldFunction"
},
"lambda": {
"payload": {},
"environmentVariables": {},
"runtime": "go1.x"
}
},
{
"type": "aws-sam",
"request": "direct-invoke",
"name": "API sunflowers:HelloWorldFunction (go1.x)",
"invokeTarget": {
"target": "api",
"templatePath": "${workspaceFolder}/template.yaml",
"logicalId": "HelloWorldFunction"
},
"api": {
"path": "/hello",
"httpMethod": "get",
"payload": {
"json": {}
}
},
"lambda": {
"runtime": "go1.x"
}
}
]
}
But when I run sunflowers:HelloWorldFunction (go1.x), I get the following error in the AWS Toolkit output:
could not launch process: fork/exec /var/task/hello-world: function not implemented
Full error Log:
2022-08-04 18:41:12 [INFO]: Preparing to debug locally: Lambda "hello-world"
2022-08-04 18:41:12 [INFO]: Building SAM application...
2022-08-04 18:41:12 [INFO]: Command: (not started) [/opt/homebrew/bin/sam build --build-dir /tmp/aws-toolkit-vscode/vsctky6JmVn/output --template /Users/varungawande/playground/goLambdaDebug/sunflowers/template.yaml]
2022-08-04 18:41:13 [INFO]: Your template contains a resource with logical ID "ServerlessRestApi", which is a reserved logical ID in AWS SAM. It could result in unexpected behaviors and is not recommended.
2022-08-04 18:41:13 [INFO]: Building codeuri: /Users/varungawande/playground/goLambdaDebug/sunflowers/hello-world runtime: go1.x metadata: {} architecture: x86_64 functions: HelloWorldFunction
2022-08-04 18:41:13 [INFO]: Running GoModulesBuilder:Build
2022-08-04 18:41:13 [INFO]:
Build Succeeded
2022-08-04 18:41:13 [INFO]:
Built Artifacts : ../../../../../private/tmp/aws-toolkit-vscode/vsctky6JmVn/output
Built Template : ../../../../../private/tmp/aws-toolkit-vscode/vsctky6JmVn/output/template.yaml
Commands you can use next
=========================
[*] Validate SAM template: sam validate
[*] Invoke Function: sam local invoke -t ../../../../../private/tmp/aws-toolkit-vscode/vsctky6JmVn/output/template.yaml
[*] Test Function in the Cloud: sam sync --stack-name {stack-name} --watch
[*] Deploy: sam deploy --guided --template-file ../../../../../private/tmp/aws-toolkit-vscode/vsctky6JmVn/output/template.yaml
2022-08-04 18:41:14 [INFO]: Build complete.
2022-08-04 18:41:14 [INFO]: Starting SAM application locally
2022-08-04 18:41:14 [INFO]: AWS.running.command
Invoking hello-world (go1.x)
Skip pulling image and use local one: public.ecr.aws/sam/emulation-go1.x:rapid-1.53.0-x86_64.
Mounting /tmp/aws-toolkit-vscode/vsctky6JmVn/output/HelloWorldFunction as /var/task:ro,delegated inside runtime container
START RequestId: 8cc3eb7a-20f2-4599-81bc-2f29f8d02102 Version: $LATEST
API server listening at: [::]:5858
2022-08-04T13:11:16Z warning layer=rpc Listening for remote connections (connections are not authenticated nor encrypted)
2022-08-04T13:11:16Z info layer=debugger launching process with args: [/var/task/hello-world]
2022-08-04 18:41:16 [INFO]: Waiting for SAM application to start...
could not launch process: fork/exec /var/task/hello-world: function not implemented
2022/08/04 13:11:16 exit status 1
04 Aug 2022 13:11:16,067 [ERROR] (rapid) Init failed error=Runtime exited with error: exit status 1 InvokeID=
API server listening at: [::]:5858
2022-08-04T13:11:16Z warning layer=rpc Listening for remote connections (connections are not authenticated nor encrypted)
2022-08-04T13:11:16Z info layer=debugger launching process with args: [/var/task/hello-world]
could not launch process: fork/exec /var/task/hello-world: function not implemented
2022/08/04 13:11:16 exit status 1
END RequestId: 0dcb2785-a232-41aa-8f78-f61c82add96b
REPORT RequestId: 0dcb2785-a232-41aa-8f78-f61c82add96b Init Duration: 1.26 ms Duration: 838.60 ms Billed Duration: 839 ms Memory Size: 128 MB Max Memory Used: 128 MB
2022-08-04 18:41:17 [INFO]: Attaching debugger to SAM application...
Command stopped: "sam local invoke"
2022-08-04 18:41:23 [ERROR]: Retry limit reached while trying to attach the debugger.
2022-08-04 18:41:23 [ERROR]: Unable to attach Debugger. Check AWS Toolkit logs. If it took longer than expected to start, you can still attach.
sam local start-api and sam local invoke still work.
The path they mounted at /tmp/aws-toolkit-vscode/vsctky6JmVn/output/HelloWorldFunction does have the file they're looking for.
❯ tree /tmp/aws-toolkit-vscode/vsctky6JmVn/output/HelloWorldFunction
/tmp/aws-toolkit-vscode/vsctky6JmVn/output/HelloWorldFunction
└── hello-world
The hello-world program does have a main function:
package main
import (
"errors"
"fmt"
"io/ioutil"
"net/http"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
var (
// DefaultHTTPGetAddress Default Address
DefaultHTTPGetAddress = "https://checkip.amazonaws.com"
// ErrNoIP No IP found in response
ErrNoIP = errors.New("No IP in HTTP response")
// ErrNon200Response non 200 status code in response
ErrNon200Response = errors.New("Non 200 Response found")
)
func handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
str := "Hello World"
str = exclaim(str)
for i := 3; i < 30; i++ {
str = exclaim(str)
fmt.Println(str, "at", i)
}
resp, err := http.Get(DefaultHTTPGetAddress)
if err != nil {
return events.APIGatewayProxyResponse{}, err
}
if resp.StatusCode != 200 {
return events.APIGatewayProxyResponse{}, ErrNon200Response
}
ip, err := ioutil.ReadAll(resp.Body)
if err != nil {
return events.APIGatewayProxyResponse{}, err
}
if len(ip) == 0 {
return events.APIGatewayProxyResponse{}, ErrNoIP
}
return events.APIGatewayProxyResponse{
Body: fmt.Sprintf("Hello, %v", string(ip)),
StatusCode: 200,
}, nil
}
func main() {
lambda.Start(handler)
}
func exclaim(str string) string {
return str + "!"
}
Note: I'm on a Mac, using the M1 chip(Arch: arm64) but the build-file is being executed for x86-64.
hello-world: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=O4tsTAbXATrthCbExZYS/IcUitw8QuK2KVYZ9ln5Y/QZl7mLeZv6TDrrYMwafh/81ITMlD5ZHrz3gae1BfY, with debug_info, not stripped```
Since it can find the file, Does this mean that the executor can't find the main?

AWS SAM Template.yaml deploy does not use-container from launch.json in VSC

Using Visual Studio Code (VSC), I can get my Lambda's running locally and they build in a container, but when I go to deploy a container is not used, it's almost like it's ignoring the launch.json file. Are there other parameters I need to add for a deployment to work? The problem in the end is that Python is not found.
When debugging locally
2022-05-09 23:17:19 [INFO]: Preparing to debug locally: Lambda "app.lambda_handler"
2022-05-09 23:17:19 [INFO]: Building SAM application...
2022-05-09 23:17:19 [INFO]: Running command: (not started) [C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd build --build-dir C:\Users\user\AppData\Local\Temp\aws-toolkit-vscode\vsctkqEogcB\output --template C:/code/MyProject/template.yaml --use-container --manifest C:\Users\user\AppData\Local\Temp\aws-toolkit-vscode\vsctkqEogcB\debug-requirements.txt]
2022-05-09 23:17:23 [INFO]: Starting Build inside a container
2022-05-09 23:17:23 [INFO]: Building codeuri: C:\code\MyProject\get-weather runtime: python3.7 metadata: {} architecture: x86_64 functions: ['GetWeatherFunction']
2022-05-09 23:17:24 [INFO]:
Fetching public.ecr.aws/sam/build-python3.7:latest-x86_64 Docker container image....
2022-05-09 23:17:24 [INFO]: ..
2022-05-09 23:17:24 [INFO]:
Mounting C:\code\EarthwiseGlobal\get-weather as /tmp/samcli/source:ro,delegated inside runtime container
When doing a deployment
2022-05-09 23:21:31 [INFO]: Starting SAM Application deployment...
2022-05-09 23:21:31 [INFO]: Building SAM Application...
2022-05-09 23:21:31 [INFO]: Running command: (not started) [C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd build --build-dir C:\Users\user\AppData\Local\Temp\aws-toolkit-vscode\samDeployLHRBc5\build --template c:\code\MyProject\template.yaml]
2022-05-09 23:21:35 [INFO]: Building codeuri: c:\code\MyProject\get-weather runtime: python3.7 metadata: {} architecture: x86_64 functions: ['GetWeatherFunction']
2022-05-09 23:21:35 [INFO]: requirements.txt file not found. Continuing the build without dependencies.
2022-05-09 23:21:35 [INFO]:
Build Failed
2022-05-09 23:21:35 [INFO]: Error: PythonPipBuilder:Validation - Binary validation failed for python, searched for python in following locations : ['C:\\Users\\user\\AppData\\Local\\Microsoft\\WindowsApps\\python.EXE', 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python310\\python.EXE'] which did not satisfy constraints for runtime: python3.7. Do you have python for runtime: python3.7 on your PATH?
Template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: MyProject Serverless
Parameters:
ENV:
Description: 'Required. The environment for the deployment'
Type: 'String'
Globals:
Function:
Timeout: 3
Layers:
- !Sub arn
Environment:
Variables:
ENV: !Ref ENV
Architectures:
- x86_64
Resources:
GetWeatherFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: get-weather
CodeUri: get-weather/
Timeout: 30
Handler: app.lambda_handler
Runtime: python3.7
Policies:
- AWSLambdaBasicExecutionRole
- AmazonSSMReadOnlyAccess
launch.json
{
"version": "0.2.0",
"configurations": [
"type": "aws-sam",
"request": "direct-invoke",
"name": "GetWeatherFunction",
"invokeTarget": {
"target": "template",
"templatePath": "${workspaceFolder}/template.yaml",
"logicalId": "GetWeatherFunction"
},
"aws": {
"region": "us-east-1"
},
"sam": {
"containerBuild": true
},
"lambda": {
"memoryMb": 128,
"timeoutSec": 10,
"environmentVariables": {
"ENV": "DEV"
},
"payload": {
"json": {}
}
}
}
]
}
settings.json
{
"python.terminal.activateEnvInCurrentTerminal": true,
"python.defaultInterpreterPath": "${workspaceFolder}\\.venv\\Scripts\\Python.exe",
"python.terminal.activateEnvironment": true,
"terminal.integrated.env.windows": {"PYTHONPATH": "${workspaceFolder}\\.venv\\Scripts\\Python.exe"}
}
SAM version
sam --version
SAM CLI, version 1.46.0

How to start airflow-scheduler pod for Google Cloud Composer?

A Composer cluster went down because its airflow-worker pods needed a Docker image that was not accessible.
Now access to the Docker image was restore, but the airflow-scheduler pod has disappeared.
I tried updating the Composer Environment by setting a new Environment Variable, with the following error :
UPDATE operation on this environment failed X minutes ago with the following error message: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({
"Date": "recently",
"Audit-Id": "my-own-audit-id",
"Content-Length": "236",
"Content-Type": "application/json",
"Cache-Control": "no-cache, private"
})
HTTP response body: {
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "deployments.apps \"airflow-scheduler\" not found",
"reason": "NotFound",
"details": {
"name": "airflow-scheduler",
"group": "apps",
"kind": "deployments"
},
"code": 404
}
Error in Composer Agent
How can I launch a airflow-scheduler pod on my Composer cluster ?
What is the .yaml configuration file I need to apply ?
I tried launching the scheduler from inside another pod with airflow scheduler, and while it effectively starts a scheduler, it's not a Kubernetes pod and will not integrate well with the managed airflow cluster.
To restart the airflow-scheduler, run the following
# Fetch the old deployment, and pipe it into the replace command.
COMPOSER_WORKSPACE=$(kubectl get namespace | egrep -i 'composer|airflow' | awk '{ print $1 }')
kubectl get deployment airflow-scheduler --output yaml \
--namespace=${COMPOSER_WORKSPACE}| kubectl replace --force -f -

Running "taco create" fails with "SyntaxError: Unexpected token ILLEGAL"

New to TACO and I'm following the Getting Started with TACO-CLI. Sadly I am getting an error when running this create command:
taco create hello
Here's the error I'm getting:
$ taco create hello
Downloading: taco-kits
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\kyle\AppData\Roaming\taco_home\node_modules\taco-kits\latest\package.json'
npm WARN latest No description
npm WARN latest No repository field.
npm WARN latest No README data
npm WARN latest No license field.
taco-kits downloaded and installed.
Error: Cannot find module 'C:\Users\kyle\AppData\Roaming\taco_home\node_modules\taco-kits\latest\node_modules\taco-kits'
SyntaxError: Unexpected token ILLEGAL
I have these versions of stuff:
npm 3.9.6
taco 1.2.1
node 6.2.1
Windows 10 (latest updates)
I've also tried with the latest stable version of node (4.4.5) and no joy.
Indeed, the contents of 'C:\Users\kyle\AppData\Roaming\taco_home\node_modules\taco-kits\latest\' does not contain a package.json file. Here's what I see there:
node_modules
timestamp.txt
The 'C:\Users\kyle\AppData\Roaming\taco_home\node_modules\taco-kits\latest\node_modules\taco-kits' contains this:
LICENSE
TacoKitMetadata.json
node_modules
package.json
resources
tacoErrorCodes.js
tacoErrorHelper.js
tacoKits.js
templates
test
The package.json file in that folder contains the following:
{
"name": "taco-kits",
"description": "Validated Kits metadata for taco CLI",
"version": "1.2.0",
"author": {
"name": "Microsoft Corporation",
"email": "vscordovatools-admin#microsoft.com"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Microsoft/TACO.git"
},
"bugs": {
"url": "https://github.com/Microsoft/TACO/issues",
"email": "vscordovatools-admin#microsoft.com"
},
"homepage": "http://taco.tools",
"main": "tacoKits.js",
"scripts": {
"test": "mocha",
"coverage": "istanbul cover --report json node_modules/mocha/bin/_mocha -- --reporter spec"
},
"dependencies": {
"q": "^1.1.2",
"taco-utils": "^1.3.3"
},
"devDependencies": {
"mocha": "2.0.1",
"istanbul": "^0.4.0",
"should": "4.3.0",
"taco-tests-utils": "^0.1.4"
},
"license": "MIT",
"_id": "taco-kits#1.2.0",
"_shasum": "7e9281a34e59cfb64234057e6ada10a99791a6ef",
"_resolved": "https://registry.npmjs.org/taco-kits/-/taco-kits-1.2.0.tgz",
"_from": "taco-kits#latest",
"_npmVersion": "2.14.9",
"_nodeVersion": "0.12.9",
"_npmUser": {
"name": "vsmobile",
"email": "vscordovatools-admin#microsoft.com"
},
"dist": {
"shasum": "7e9281a34e59cfb64234057e6ada10a99791a6ef",
"tarball": "https://registry.npmjs.org/taco-kits/-/taco-kits-1.2.0.tgz"
},
"maintainers": [
{
"name": "vsmobile",
"email": "vscordovatools-admin#microsoft.com"
}
],
"directories": {}
}
Any help would be appreciated.
Update (resolved)
I was able to resolve this issue by deleting the taco-kits folder and then running taco kit list which reinstalled the kits. The bash commands I used are as follows (using bash):
rm -Rf /c/users/kyle/AppData/Roaming/taco_home/node_modules/taco-kits/
taco kit list
I'd suggest just renaming that taco-kits folder first just to make sure it works for you.

No Ports Assigned to Strongloop App

I am attempting to deploy a strongloop app to a Digitalocean remote box running Strongloop Process Manager. I have gotten as far as successfully running the deploy command as follows:
USER ~/projects/loopback/places-api $ slc deploy http://IPADDRESS deploy
Counting objects: 5215, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4781/4781), done.
Writing objects: 100% (5215/5215), 7.06 MiB | 4.27 MiB/s, done.
Total 5215 (delta 1130), reused 0 (delta 0)
To http://104.131.66.124:8701/api/services/1/deploy/default
* [new branch] deploy -> deploy
Deployed `deploy` as `placesAPI` to `http://IPADDRESS:8701/`
Next, I check the status of my Strongloop app by running the following command:
slc ctl -C http://IPADDRESS:8701
Service ID: 1
Service Name: placesAPI
Environment variables:
No environment variables defined
Instances:
Version Agent version Debugger version Cluster size Driver metadata
5.1.0 2.0.2 n/a 1 N/A
Processes:
ID PID WID Listening Ports Tracking objects? CPU profiling? Tracing? Debugging?
1.1.1050 1050 0
1.1.2065 2065 49
At this point, I am not able to access my app by visiting IPADDRESS:3001 as the Strongloop documentation would suggest and there are no processes listed in the above app status running on port 3001 as would be expected according to the Strongloop documentation.
Comparing my app status to the app status at this state of deployment shown in the Strongloop documentation, It appears I should have some processes listening to port 3001 which are not running in my app.
Here is the app status shown in the Strongloop documentation:
$ slc ctl -C http://prod.foo.com:7777
Service ID: 1
Service Name: appone
Environment variables:
No environment variables defined
Instances:
Version Agent version Cluster size
4.0.30 1.4.15 4
Processes:
ID PID WID Listening Ports Tracking objects? CPU profiling?
1.1.22555 22555 0
1.1.22741 22741 5 prod.foo.com:3001
1.1.22748 22748 6 prod.foo.com:3001
1.1.22773 22773 7 prod.foo.com:3001
1.1.22793 22793 8 prod.foo.com:3001
Notice the additional processes listening to port 3001.
My question is: how do I get my strongloop app to run and listen to these ports?
If it helps here are my package.json and config.json files:
:::::::::::::::::::::::package.json::::::::::::::::
{
"name": "placesAPI",
"version": "1.0.0",
"main": "server/server.js",
"scripts": {
"start": "node .",
"pretest": "jshint ."
},
"dependencies": {
"body-parser": "^1.9.0",
"compression": "^1.0.3",
"connect-ensure-login": "^0.1.1",
"cookie-parser": "^1.3.2",
"cors": "^2.5.2",
"errorhandler": "^1.1.1",
"express-flash": "0.0.2",
"express-session": "^1.7.6",
"jade": "^1.7.0",
"loopback": "^2.22.0",
"loopback-boot": "^2.6.5",
"loopback-component-explorer": "^2.1.0",
"loopback-component-passport": "^1.5.0",
"loopback-connector-postgresql": "^2.4.0",
"loopback-datasource-juggler": "^2.39.0",
"passport": "^0.3.2",
"passport-facebook": "^1.0.3",
"passport-google-oauth": "^0.2.0",
"passport-local": "^1.0.0",
"passport-oauth2": "^1.1.2",
"passport-twitter": "^1.0.3",
"serve-favicon": "^2.0.1"
},
"devDependencies": {
"jshint": "^2.5.6"
},
"repository": {
"type": "",
"url": ""
},
"description": "placesAPI",
"bundleDependencies": [
"body-parser",
"compression",
"connect-ensure-login",
"cookie-parser",
"cors",
"errorhandler",
"express-flash",
"express-session",
"jade",
"loopback",
"loopback-boot",
"loopback-component-explorer",
"loopback-component-passport",
"loopback-connector-postgresql",
"loopback-datasource-juggler",
"passport",
"passport-facebook",
"passport-oauth2",
"serve-favicon"
]
}
:::::::::::::::::::::::config.json::::::::::::::::
{
"restApiRoot": "/api",
"host": "0.0.0.0",
"port": 3000,
"cookieSecret": "REDACTED",
"remoting": {
"context": {
"enableHttpContext": false
},
"rest": {
"normalizeHttpPath": false,
"xml": false
},
"json": {
"strict": false,
"limit": "100kb"
},
"urlencoded": {
"extended": true,
"limit": "100kb"
},
"cors": false,
"errorHandler": {
"disableStackTrace": false
}
},
"legacyExplorer": false
}
There is also this error in the logs from log-dump:
2015-12-23T22:13:35.876Z pid:2720 worker:84 events.js:142
2015-12-23T22:13:35.882Z pid:2720 worker:84 throw er; // Unhandled 'error' event
2015-12-23T22:13:35.882Z pid:2720 worker:84 ^
2015-12-23T22:13:35.882Z pid:2720 worker:84 Error: connect ECONNREFUSED 127.0.0.1:5432
2015-12-23T22:13:35.882Z pid:2720 worker:84 at Object.exports._errnoException (util.js:856:11)
2015-12-23T22:13:35.882Z pid:2720 worker:84 at exports._exceptionWithHostPort (util.js:879:20)
2015-12-23T22:13:35.883Z pid:2720 worker:84 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1064:14)
2015-12-23T22:13:35.919Z pid:1106 worker:0 ERROR supervisor worker id 84 (pid 2720) accidental exit with 1
2015-12-23T22:13:38.253Z pid:1106 worker:0 INFO supervisor started worker 85 (pid 2738)
2015-12-23T22:13:38.253Z pid:1106 worker:0 INFO supervisor resized to 1
2015-12-23T22:13:39.858Z pid:2738 worker:85 INFO strong-agent native addon missing, install a compiler
2015-12-23T22:13:39.859Z pid:2738 worker:85 INFO strong-agent v2.0.2 profiling app 'placesAPI' pid '2738'
2015-12-23T22:13:39.890Z pid:2738 worker:85 INFO strong-agent[2738] started profiling agent
2015-12-23T22:13:44.943Z pid:2738 worker:85 INFO strong-agent not profiling, agent metrics requires a valid license.
2015-12-23T22:13:44.944Z pid:2738 worker:85 Please contact sales#strongloop.com for assistance.
2015-12-23T22:13:44.992Z pid:2738 worker:85 Web server listening at: http://0.0.0.0:3001
2015-12-23T22:13:44.997Z pid:2738 worker:85 Browse your REST API at http://0.0.0.0:3001/explorer
2015-12-23T22:13:45.103Z pid:2738 worker:85 Connection fails: { [Error: connect ECONNREFUSED 127.0.0.1:5432]
2015-12-23T22:13:45.104Z pid:2738 worker:85 code: 'ECONNREFUSED',
2015-12-23T22:13:45.104Z pid:2738 worker:85 errno: 'ECONNREFUSED',
2015-12-23T22:13:45.104Z pid:2738 worker:85 syscall: 'connect',
2015-12-23T22:13:45.104Z pid:2738 worker:85 address: '127.0.0.1',
2015-12-23T22:13:45.104Z pid:2738 worker:85 port: 5432 }
2015-12-23T22:13:45.104Z pid:2738 worker:85 It will be retried for the next request.
Just to put this in an answer, from the package.json we can see that you have included the loopback-connector-postgresql and in the log we see an attempted connection to port 5432 which is the default for that DBMS. It's trying to connect on the localhost (127.0.0.1) and my guess is that Postgres is either not installed on your Digital Ocean box, or not running. You'll need to update the config for your DB, or install (and run) the DB on your DO droplet.
If you have different configs for dev vs production then you can set up an environment-specific datasources config file: datasources.production.json for example. In that file you would put your prod config, and in datasources.json you would have your dev (local) config. When using this method, be sure to set the NODE_ENV variable on your DO droplet to production (to match the name of the prod datasources config file).