brooklyncentral / clocker

Apache Brooklyn cloud native infrastructure blueprints
Apache License 2.0
428 stars 66 forks source link

node.js demo app fails (node.js incorrectly trying to reach redis on 127.0.0.1:6379). #303

Closed aledsage closed 8 years ago

aledsage commented 8 years ago

After fixing https://github.com/brooklyncentral/clocker/issues/298, I deployed the "Node.js Demo Application" but it failed (when waiting for service-up for the node.js entity).

Looking on the container at the console.out file, it contains:

Wed, 04 May 2016 23:09:54 GMT body-parser deprecated bodyParser: use individual json/urlencoded middlewares at server.js:31:9
Wed, 04 May 2016 23:09:54 GMT body-parser deprecated undefined extended: provide extended option at node_modules/body-parser/index.js:75:29
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
    at RedisClient.on_error (/home/users/aled/brooklyn-managed-processes/apps/afGGKBDy/entities/NodeJsWebAppService_xKDWLsSL/nodejs-todo/node_modules/redis/index.js:189:24)
    at Socket.<anonymous> (/home/users/aled/brooklyn-managed-processes/apps/afGGKBDy/entities/NodeJsWebAppService_xKDWLsSL/nodejs-todo/node_modules/redis/index.js:95:14)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at emitErrorNT (net.js:1265:8)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Searching the debug log for REDISTOGO_URL, I see it logged while provisioning the VM, e.g. the line below, but not subsequently.

2016-05-05 00:08:25,453 DEBUG o.a.b.e.s.b.l.MachineLifecycleEffectorTasks [brooklyn-execmanager-C1IihSf8-107]: While starting NodeJsWebAppServiceImpl{id=xKDWLsSL}, obtained new location instance SshMachineLocation[10.101.1.165:aled@10.101.1.165/10.101.1.165:32770(id=TOvjelM5)], details aled:{entity=NodeJsWebAppServiceImpl{id=xKDWLsSL}, machine=SshMachineLocation[10.101.1.165:aled@10.101.1.165/10.101.1.165:32770(id=uPOvV0Ev)], displayName=10.101.1.165, address=10.101.1.165/10.101.1.165, privateKeyData=xxxxxxxx, config={privateKeyData=xxxxxxxx}, user=aled, jcloudsParent=JcloudsLocation[docker:https://10.101.1.165:2376:/Users/aled/temp/tempbasedir/docker-certs/fa7iG2NE-cert.pem/docker:https://10.101.1.165:2376@xhF0kuns], node={id=b31c35c08bce4946eccfc91251c4d86ab9373bd0b0c04a2e73b1f8e7a10b823f, providerId=b31c35c08bce4946eccfc91251c4d86ab9373bd0b0c04a2e73b1f8e7a10b823f, name=nodejs_xkdwlssl, location={scope=PROVIDER, id=docker, description=https://10.101.1.165:2376}, group=nodejs_xkdwlssl, imageId=sha256:882a1b87be0b64dbab5730439d4c54b3601c42d2b799af13830785be091e8939, os={family=unrecognized, version=latest, description=tkjkm3ancayr:latest, is64Bit=true}, status=RUNNING, loginPort=32770, hostname=nodejs_xkdwlssl, privateAddresses=[], publicAddresses=[10.101.1.165], hardware={id=, processors=[{cores=0.0, speed=0.0}], ram=0, supportsImage=ALWAYS_TRUE}, loginUser=aled}, template={image={id=sha256:882a1b87be0b64dbab5730439d4c54b3601c42d2b799af13830785be091e8939, providerId=sha256:882a1b87be0b64dbab5730439d4c54b3601c42d2b799af13830785be091e8939, name=tkjkm3ancayr, os={family=unrecognized, version=latest, description=tkjkm3ancayr:latest, is64Bit=true}, description=tkjkm3ancayr:latest, status=AVAILABLE, loginUser=root}, hardware={id=small, providerId=small, name=small, processors=[{cores=1.0, speed=1.0}], ram=1024, hypervisor=lxc, supportsImage=ALWAYS_TRUE}, location={scope=PROVIDER, id=docker, description=https://10.101.1.165:2376}, options=DockerTemplateOptions{volumes={}, hostname=nodejs_xkdwlssl, dns=[], memory=null, cpuShares=null, entrypoint=null, commands=null, env=[REDISTOGO_URL=redis://redis_za5axcqs.afGGKBDy:6379/], portBindings={}, networkMode=afGGKBDy_bridge, extraHosts={}, volumesFrom=[], privileged=true, openStdin=false, configBuilder=null}}, brooklyn.ssh.config.port=32770, password=xxxxxxxx, region=docker, callerContext=null, detectMachineDetails=true, portforwarding.enabled=true, portforwarding.forwarder=brooklyn.networking.subnet.SubnetTierImpl$SubnetTierJcloudsPortForwarderExtension@25a7e9a0, brooklyn.portforwarding.manager=PortForwardManagerImpl{id=QTmKhfeo, name=localhost, scope=global, mappingsSize=8}, provider=docker, identity=/Users/aled/temp/tempbasedir/docker-certs/fa7iG2NE-cert.pem, credential=xxxxxxxx, endpoint=https://10.101.1.165:2376, spec.final=jclouds:docker:https://10.101.1.165:2376, spec.original=jclouds:docker:https://10.101.1.165:2376, machineCreationSemaphore=java.util.concurrent.Semaphore@3ef4bb13[Permits = 2147483647], owner=DockerContainerImpl{id=MZH1eol0}, brooklyn.ssh.config.host=10.101.1.165, host=10.101.1.165, port=32770}

Could this environment variable perhaps not be set when we are launching node.js? When I look in the web-console at the activity for launch, then the only environment variables it lists are: PORT="3000".

aledsage commented 8 years ago

Fixed by https://github.com/brooklyncentral/clocker/pull/306