Skip to content

Commit

Permalink
Fixes null pointer exception when run without main command (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross authored Jan 27, 2017
1 parent 6437b19 commit 4dec7fb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ func (a *App) Run() {
if err != nil {
log.Errorf("Unable to parse command arguments: %v", err)
}
cmd.Name = "APP"
a.Command = cmd

a.handleSignals()
Expand All @@ -160,6 +159,7 @@ func (a *App) Run() {
a.handlePolling()

if a.Command != nil {
cmd.Name = "APP"
// Run our main application and capture its stdout/stderr.
// This will block until the main application exits and then os.Exit
// with the exit code of that application.
Expand Down
6 changes: 6 additions & 0 deletions integration_tests/tests/test_no_command/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
app:
image: "cpfix_app"
mem_limit: 128m
volumes:
- '${CONTAINERPILOT_BIN}:/bin/containerpilot:ro'
command: /bin/containerpilot
14 changes: 14 additions & 0 deletions integration_tests/tests/test_no_command/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

logFail() {
echo "${1}"
exit 1
}

docker-compose run -d app
TEST_ID=$(docker ps -a | awk -F' +' '/testnocommand/{print $1}')
docker logs $TEST_ID | grep -qv panic
result=$?
docker stop $TEST_ID || logFail 'should still be running'
docker rm $TEST_ID
exit $result

0 comments on commit 4dec7fb

Please sign in to comment.