# Bc\_connect app: Wait for process to start before displaying Connect

**URL:** <https://discourse.openondemand.org/t/bc-connect-app-wait-for-process-to-start-before-displaying-connect/2376>\
**Category:** Get Help\
**Created:** [November 17, 2022, 7:55pm UTC](https://discourse.openondemand.org/t/bc-connect-app-wait-for-process-to-start-before-displaying-connect/2376 "2022-11-17T19:55:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pakalee](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/pakalee/32/1155_2.png) [@pakalee](https://discourse.openondemand.org/u/pakalee)\
**Post date:** [November 17, 2022, 7:55pm UTC](https://discourse.openondemand.org/t/bc-connect-app-wait-for-process-to-start-before-displaying-connect/2376/1 "2022-11-17T19:55:26Z")

</div>

For a batch connect / interactive app: How would I wait for the process started in template/script.sh to reach a checkpoint _before_ displaying the Connect button for the user?

For example, a web service like Galaxy takes a _long_ time to start up. If the user immediately hits Connect, the server is not running yet.

---

<div class="post-metadata">

**Author:** ![travert](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/travert/32/3074_2.png) [@travert](https://discourse.openondemand.org/u/travert)\
**Post date:** [November 18, 2022, 3:44pm UTC](https://discourse.openondemand.org/t/bc-connect-app-wait-for-process-to-start-before-displaying-connect/2376/2 "2022-11-18T15:44:38Z")

</div>

Hi and thanks for the question.

The trick here will be to use the `after.sh` script.

What is happening is OOD is waiting for that `connection.yml` file to be written before it displays the connect button for the user, and this is in turn waiting on things like the `port` to be open. But, clearly more time is needed to connect for this app than just waiting for the `port` to open and the `connection.yml` to be written.

I’d recommend trying to find out a definitive part of Galaxy that you can issue a shell command to know if it is in fact up and running, or use something like `sleep` to wait some known safe period of time, in that `after.sh` script to handle this.

---

<div class="post-metadata">

**Author:** ![pakalee](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/pakalee/32/1155_2.png) [@pakalee](https://discourse.openondemand.org/u/pakalee)\
**Post date:** [November 18, 2022, 6:33pm UTC](https://discourse.openondemand.org/t/bc-connect-app-wait-for-process-to-start-before-displaying-connect/2376/3 "2022-11-18T18:33:04Z")

</div>

OK, thanks. I think this may work in `after.sh` (assuming `$srv_url` has been exported by `before.sh`):

```auto
# wait for the Galaxy gunicorn process to be ready
timeout 30 grep -q "Listening at: $srv_url" <(tail -f output.log)

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/b/bae70bd0ed39a3ae769c2108155f4cb3e9da8385.png) [@system](https://discourse.openondemand.org/u/system)\
**Post date:** [May 17, 2023, 6:33pm UTC](https://discourse.openondemand.org/t/bc-connect-app-wait-for-process-to-start-before-displaying-connect/2376/4 "2023-05-17T18:33:39Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
