hemerajs / aither

An example microservice system in Node.js using Hemera and best of today.
GNU General Public License v3.0
119 stars 26 forks source link

"Could not connect to NATS!" #3

Closed NigelThorne closed 7 years ago

NigelThorne commented 7 years ago

I'm getting this message looping while the services are running.

cache-service_1        | [2017-09-19T09:09:31.776Z] INFO (hemera-9c62d65821b7-ca4d19e8803e41368b57f8d0c7723ffe/1 on 9c62d65821b7): hemera-joi PLUGIN - ADDED!
cache-service_1        | [2017-09-19T09:09:31.782Z] INFO (hemera-9c62d65821b7-ca4d19e8803e41368b57f8d0c7723ffe/1 on 9c62d65821b7): hemera-redis-cache PLUGIN - ADDED!
cache-service_1        | [2017-09-19T09:09:31.836Z] ERROR (NatsError/1 on 9c62d65821b7): Could not connect to NATS!
cache-service_1        |     Error
cache-service_1        |         at Socket.<anonymous> (/usr/src/app/node_modules/nats/lib/nats.js:454:28)
cache-service_1        |         at emitOne (events.js:96:13)
cache-service_1        |         at Socket.emit (events.js:188:7)
cache-service_1        |         at connectErrorNT (net.js:1025:8)
cache-service_1        |         at _combinedTickCallback (internal/process/next_tick.js:74:11)
cache-service_1        |         at process._tickCallback (internal/process/next_tick.js:98:9)
cache-service_1        | [2017-09-19T09:09:31.839Z] ERROR (hemera-9c62d65821b7-ca4d19e8803e41368b57f8d0c7723ffe/1 on 9c62d65821b7): NATS Code: 'CONN_ERR', Message: Could not connect to server: Error: getaddrinfo ENOTFOUND nats nats:4222
cache-service_1        | [2017-09-19T09:09:31.847Z] WARN (hemera-9c62d65821b7-ca4d19e8803e41368b57f8d0c7723ffe/1 on 9c62d65821b7): NATS disconnected!
NigelThorne commented 7 years ago

I've done some digging.... NATS is not starting up from the docker file. The images build fine as far as I can see.

These are the containers running.

λ docker container ls -a                                                                                                                                                                                   
CONTAINER ID        IMAGE                            COMMAND                  CREATED             STATUS                          PORTS                                          NAMES                     
c673d293578d        aither_cache-service             "node ."                 15 minutes ago      Restarting (0) 11 seconds ago                                                  aither_cache-service_1    
73aba3cdecc2        aither_math-service              "node ."                 15 minutes ago      Restarting (0) 3 seconds ago                                                   aither_math-service_1     
6b062b374b92        aither_api                       "node ."                 15 minutes ago      Exited (0) 6 minutes ago                                                       aither_api_1              
19b6458a6a18        aither_natsboard                 "node ./node_modul..."   15 minutes ago      Up 6 minutes                    0.0.0.0:3000-3001->3000-3001/tcp               aither_natsboard_1        
c7bd53e6a5d4        openzipkin/zipkin                "/bin/sh -c 'test ..."   15 minutes ago      Up 6 minutes                    0.0.0.0:9410-9411->9410-9411/tcp               zipkin                    
803da0eebdd0        openzipkin/zipkin-dependencies   "crond -f"               15 minutes ago      Up 6 minutes                                                                   zipkin-dependencies       
529f51df041e        openzipkin/zipkin-mysql          "/bin/sh -c /mysql..."   15 minutes ago      Up 6 minutes                    3306/tcp                                       mysql                     
97b401f8c48e        aither_nats                      "/entrypoint.sh gn..."   15 minutes ago      Exited (1) 6 minutes ago                                                       aither_nats_1             
7f250a8fe99e        redis:alpine                     "docker-entrypoint..."   15 minutes ago      Up 6 minutes                    0.0.0.0:6379->6379/tcp                         aither_redis_1            
711c7d110c21        traefik                          "/traefik --web --..."   15 minutes ago      Up 6 minutes                    0.0.0.0:8182->80/tcp, 0.0.0.0:8181->8080/tcp   aither_traefik_1          
a82e7674be24        231fd6ad201c                     "/entrypoint.sh -i"      20 minutes ago      Exited (1) 20 minutes ago                                                      jovial_raman              
6f2e24a5af6c        231fd6ad201c                     "/entrypoint.sh gn..."   23 minutes ago      Exited (1) 23 minutes ago                                                      loving_montalcini         
46d44d3ed617        aither_nats                      "/entrypoint.sh gn..."   24 minutes ago      Exited (1) 24 minutes ago                                                      agitated_easley           
λ docker logs 97b4                                                                  
standard_init_linux.go:187: exec user process caused "no such file or directory"    
standard_init_linux.go:187: exec user process caused "no such file or directory"    
standard_init_linux.go:187: exec user process caused "no such file or directory"                                                                                        

api died as it can't connect to nats. HAHA!! found it..

I ran docker run -it --entrypoint /bin/sh aither_nats and the entrypoint script would not run.

then I ran vi entrypoingscript.sh and found ^M at the end of every line!

So... running from windows.. with GIT automatically changing the line endings... screws everything!

git config core.eol lf
git config core.autocrlf false
rm .git/index
git reset
git clean -f -d
git reset --hard
docker-compose down
docker-compose build
docker-compose up

and.... DONE!

StarpTech commented 7 years ago

Hi @NigelThorne thanks for reporting and investigating. If you have any other question open an issue.