How to get projectId, environmentId, and serviceId programmatically

zapPRO

7 months ago

Inside a server I have running, I need to upsert an environment variable to the server it runs on. But I don't have the projectId, environmentId, and serviceId to do so. How can I get this information inside the server to make the request to upsert an environment variable?

0 Replies

zapPRO

7 months ago

N/A


7 months ago

To be honest this feels more like an XY question, so can you tell me the usecase?


zapPRO

7 months ago

I was going to store a session for a user logging into a server. These sessions are kept almost indefinitely, so was going to store them as environment variables.


zapPRO

7 months ago

But can just store in a database somewhere, no problem


zapPRO

7 months ago

But now that I have you here, I have another question.


zapPRO

7 months ago

I will be spinning up a server per user and will use the Public API to do that.

How would I create a project connected to a Github Repo with specific environment variables and allow public networking on a specific port?

Are the public network domains predictable? Meaning I will need to access each user's server through the public network (it's an API), and I will need to be able to predict, if possible, the URL for each project.


zapPRO

7 months ago

Ideally, I can create everything in 1 request, as I see the rate limiting is 1000 requests per hour.


7 months ago

100% store sessions in a database and not environment variables.

As for spinning up a Railway service for every user, I can not recommend enough for you to not do that, It will not be scalable in the slightest, even if you can do it in a single request. Please look into writing a multi-tenant app instead.


zapPRO

7 months ago

Will get back to you on this


zapPRO

7 months ago

Is it okay if I send you a DM @Brody? Have a couple questions regarding this and would prefer not to mention our use case here


7 months ago

thank you for asking, but please say what you need to here


zapPRO

7 months ago

So, for our use case, obviously, having one server per user is never ideal; multi-tenant is the best. But our specific use case is we are building a Telegram client that logs in to users' Telegram accounts and monitors their messages. We want to use a single GitHub repository of a NodeJS server on Railway that will run the user's Telegram Client. The code for every service will be 100% the same, with the only thing changing being the sessions they are logged in to + environment variables. To host this all on Railway as separate servers would only cost us ~$1-5 per month per user under their separate service; the rest of our application is hosted multi-tenant by sharing a single database, website dashboard, etc.

I wanted to reach out personally to see if Railway has any limitations that will stop us from spinning up thousands of servers (one per user). In the future, we will most likely switch to something like Kubernetes, but it is not worth the time investment right now.


zapPRO

7 months ago

This makes it relatively easy to share the same GitHub repo for all servers and have automatic deployments per push to each server.

With all of that information, I would like to see if there are any potential rate limits or issues you foresee me running into with Railway with this architecture.


7 months ago

no we do not have limitations in that regard, we have a few users with hundreds of services on their canvases, but that creates an absolutely horrible experience since the canvas style is not designed for such use cases.

Please invest your time into creating a multi-tenant telegram bot, your time would be better spent doing that then figuring out how to hook into Railway's API


How to get projectId, environmentId, and serviceId programmatically - Railway Help Station