arangodb / arangodb-php

PHP ODM for ArangoDB
https://www.arangodb.com
Apache License 2.0
183 stars 43 forks source link

Q: Why is Travis hanging on shutdown ? #203

Closed sandrokeil closed 7 years ago

sandrokeil commented 7 years ago

I have an integration test with ArangoDB and I use a similiar Travis config/setup file like in this repo. But at the end, Travis does not shutdown.

The output of Travis is the following and the last two lines are from ArangoDB.

Done. Your build exited with 0.
2016-12-16T17:21:44Z [2756] INFO hangup received, about to reopen logfile
2016-12-16T17:21:44Z [2756] INFO hangup received, reopened logfile

This error occurs with version 3.0.12 and 3.1.5. Any ideas why this happen? This is my connection config:

ConnectionOptions::OPTION_AUTH_TYPE => 'Basic',
ConnectionOptions::OPTION_CONNECTION => 'Close',
ConnectionOptions::OPTION_TIMEOUT => 3,
ConnectionOptions::OPTION_RECONNECT => false,
ConnectionOptions::OPTION_CREATE => false,
ConnectionOptions::OPTION_UPDATE_POLICY => UpdatePolicy::LAST,
ConnectionOptions::OPTION_AUTH_USER => $GLOBALS['arangodb_username'],
ConnectionOptions::OPTION_AUTH_PASSWD => $GLOBALS['arangodb_password'],
ConnectionOptions::OPTION_ENDPOINT => $GLOBALS['arangodb_host'],
ConnectionOptions::OPTION_DATABASE => $GLOBALS['arangodb_dbname'],
jsteemann commented 7 years ago

I think it's because the script is invoking arangod from the shell with the & control operator. This will put arangod in the background and it won't stop unless explicitly stopped or unless the invoking shell terminates:

 ${ARANGOD} \
    --database.directory ${TMP_DIR} \
    --configuration none \
    --server.endpoint tcp://127.0.0.1:8529 \
    --javascript.app-path ${ARANGODB_DIR}/js/apps \
    --javascript.startup-directory ${ARANGODB_DIR}/js \
    --database.maximal-journal-size 1048576 \
    --server.authentication false &

The arangod process should stop when the invoking shell terminates. Here is an example of how arangod is used in another PHP project on TravisCI and it seems to work fine there.

I am not sure if your project's integration tests do anything special, but arangod is expected to stop properly if the invoking shell terminates. If it does not, it may be worth trying to figure out what's wrong. Can you try sending the process a termination signal, wait a few seconds and then check with ps or top whether it's still there? Something like this should be sufficient to find out (provided only a single arangod instance is started for the tests):

ps fax | grep arango
killall -s SIGTERM arangod
sleep 60
ps fax | grep arango

If the arangod process is still there after 60 seconds, this would look wrong.

Apart from that, sending the process a SIGKILL signal will always terminate it, though this will be a hard shutdown.

sandrokeil commented 7 years ago

@jsteemann Ok but the script in arangodb-php has the same behaviour. Your suggestion with killall helps. Thank you.

jsteemann commented 7 years ago

Just looked at the build logs from TravisCI and it seems that in arangodb-php arangod shuts down properly when the build finishes, even without sending it some signal explicitly. In the Travis build of yours arangod seems to receive SIGHUP, at least that is what it prints out. SIGHUP however won't terminate the arangod process, only SIGINT, SIGTERM or SIGKILL. Don't know why it gets the SIGHUP in the first place.