Shih-Min Lee
Shih-Min Lee

Reputation: 9750

circleci won't finish build on successful server startup

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?

Upvotes: 0

Views: 174

Answers (1)

Jonathan Turpie
Jonathan Turpie

Reputation: 1363

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

Upvotes: 1

Related Questions