Skip to content
How to wait for the service before spin another service?

3 years ago

Just wondering how to do that. Instead of deploying the services at the same time. Is this possible?

18 Replies

3 years ago

It's not currently possible natively with Railway, the best you could do would be to use nc to wait for the database (since I'm pretty sure I know the context of this question)


3 years ago

Yup you know the context, we want to make sure that the database is running before deploying the source image.

Btw, it is working successfully now, there's an issue with our dashboard that it says that the instance or the service is not publicly accessible.


3 years ago

What happens when you visit the domain generated for the service?


3 years ago

It works here's the example: http://viaduct.proxy.rlwy.net:10511/json


3 years ago

You wouldn't want to be using the TCP proxy for HTTP, you'd want to use the HTTP proxy for HTTP.


3 years ago

How can I setup the HTTP proxy for HTTP? Generate domain?


3 years ago

Correct. But it sounds like you are using the v1 template composer, I would highly recommend you use the v2 composer -

https://railway.app/compose


3 years ago

Yeah tried that but it doesn't show a response from the browser is that intended?

In addition, how to make the public network HTTPS?


3 years ago

I'm using the compose from the dashboard.


3 years ago

Sure it does! - https://thirdweb-engine-production-ee27.up.railway.app/json

HTTPS is automatically done by Railway.


3 years ago

It works now Brody!

We can now publish the template.


3 years ago

Awsome, I look forward to giving feedback on that!


3 years ago

How about the nc thing how to do that with the setup? Where can I put that?


3 years ago

You could update the service's start command to -

/bin/sh -c "echo 'Waiting for database...'; while ! nc -z ${PGHOST_PRIVATE} ${PGPORT_PRIVATE}; do sleep 0.5; done; echo 'Database is now available'; exec /sbin/tini -- yarn start"

This means you need two additional variables on the service -

PGHOST_PRIVATE=${{Postgres.PGPRIVATEHOST}}
PGPORT_PRIVATE=5432

Tini would also like you to set a TINI_SUBREAPER variable to 1


3 years ago

Alright, the above start command will also work with "source image" not a github repo?

Tini would also like you to set a TINI_SUBREAPER variable to 1

Do I need to add this too in the env?


3 years ago

>Alright, the above start command will also work with "source image" not a github repo?

If the image is built using that Dockerfile in your repo, yes absolutely!

>>Tini would also like you to set a TINI_SUBREAPER variable to 1

>Do I need to add this too in the env?

Yeah as a service variable!


3 years ago

Hey Brody works!

Finalizing and will publish in a minute, thanks for all the help!


3 years ago

Awsome!


Welcome!

Sign in to your Railway account to join the conversation.

Loading...