# Travis-ci build runs forever after the app starts successfully

**URL:** <https://travis-ci.community/t/travis-ci-build-runs-forever-after-the-app-starts-successfully/11609>\
**Category:** Travis CI Discussions & Feedback\
**Tags:** python, travis-build\
**Created:** [May 17, 2021, 4:36pm UTC](https://travis-ci.community/t/travis-ci-build-runs-forever-after-the-app-starts-successfully/11609 "2021-05-17T16:36:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SolarUltima](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/solarultima/32/4019_2.png) [@SolarUltima](https://travis-ci.community/u/SolarUltima)\
**Post date:** [May 17, 2021, 4:36pm UTC](https://travis-ci.community/t/travis-ci-build-runs-forever-after-the-app-starts-successfully/11609/1 "2021-05-17T16:36:30Z")

</div>

it just goes forever here is my yaml:

```auto
python:
  - "3.7"

install:
  - pip3 install -r requirements.txt
  - pip3 install pytest

before_script:
  - chmod +x deploy.sh
  - chmod +x changelog.sh

branches:
  only:
    - travis-test

script:
  - python3 -m tg_companion

after_success:
  ./deploy.sh

```

im not sure what im doing wrong…

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [May 17, 2021, 4:40pm UTC](https://travis-ci.community/t/travis-ci-build-runs-forever-after-the-app-starts-successfully/11609/2 "2021-05-17T16:40:16Z")

</div>

Hard to know what _exactly_ is causing this without the log, but I suggest wrapping the start of your app in a script which kills it after a certain amount of time.

In `travis.yml`, add in your `script:` hook a file called `timeout.sh` (or whatever you want it to be named):

```auto
script:
  - timeout.sh

```

Then create a `timeout.sh` script:

```auto
#!/bin/bash

python3 -m tg_companion &

bg_pid=$!

sleep 120

kill $bg_pid

exit 0

```

Alternatively, this would be possible, in which, say you have your module notice when it is being ran in test mode, and kill itself after a timeout - possibly a command-line flag, or looking at the environment for e.g. `TRAVIS=true` or `CI=true`.

Montana Mendy  
Travis CI Staff  
Happy Building!

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [May 17, 2021, 8:01pm UTC](https://travis-ci.community/t/travis-ci-build-runs-forever-after-the-app-starts-successfully/11609/3 "2021-05-17T20:01:12Z")

</div>

> [@Run backend and frontend in parallel with tests](https://travis-ci.community/t/run-backend-and-frontend-in-parallel-with-tests/8646/4):
>
> Roughtly the same as you would do locally but using a single console prompt. E.g. run server processes in background like [https://travis-ci.community/t/running-docker-containers-in-parallel-with-tests/7046:](https://travis-ci.community/t/running-docker-containers-in-parallel-with-tests/7046:) install: - /path/to/server1 args & PIDS="$!" # a service may provide some other way to know its PID like a pidfile - /path/to/server2 args & PIDS="$PIDS $!" script: - \<run tests\> after\_script: - kill $PIDS # or shut down servers gracefully in some other service-specific way…
