0

I have setup circleCI, AWS CodeDeploy and EC2 to work together so that after I push code to git, it relays to circleCI and then EC2 and starts a server there.

Everything is working fine except the server is running correctly and circleCI won't give me a successful build status. It is always in "running" state

appspec.yml

version: 0.0
os: linux
files:
  - source: /
    destination: /home/ubuntu
permissions:
  - object: /home/ubuntu/scripts
    pattern: "**"
    mode: 777
    type:
      - file
hooks:
  ApplicationStart:
    - location: scripts/start.sh
      timeout: 3800

start.sh

#!/bin/bash
node server.js

anyone know how to solve this?

Shih-Min Lee
  • 9,350
  • 7
  • 37
  • 67

1 Answers1

1

The host agent is waiting for your script to exit. You need to run node as a daemon.

#!/bin/bash
node server.js > /var/log/my_node_log 2> /var/log/my_node_log < /dev/null &

See http://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting.html#troubleshooting-long-running-processes

Jonathan Turpie
  • 1,343
  • 10
  • 16
  • one question. I used pm2 to monitor my processes. Is there a way to make this work? It appears if I try to daemonize pm2 the pm2 won't even start.. – Shih-Min Lee Nov 03 '15 at 03:47