R
Railwayβ€’2y ago
mayank31

there is an issue regarding file transfer...

Hi, Railways is awesome. I managed to deploy my app. However, when i am trying to transfer files from railway to dropbox it doesn't seem to work. The file runs fine on my laptop. Do you think it could be a firewall issue? Any help or suggestion would be great! Thanks
40 Replies
Percy
Percyβ€’2y ago
Project ID: 5cb9ecaa-5bde-4beb-b7a3-5653ad5269a3
mayank31
mayank31OPβ€’2y ago
5cb9ecaa-5bde-4beb-b7a3-5653ad5269a3 the command i am using in docker CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port 8080 && python to_dropbox.py"] fastapi app runs fine as expected but to_dropbox.py doesn't
Jer
Jerβ€’2y ago
any err messages?
mayank31
mayank31OPβ€’2y ago
no error messages infact i don't have anything in logs i tried to print some statements just to see if it enters the function but nothing on logs i only have fastapi related logs
Jer
Jerβ€’2y ago
hmm try changing your docker file to this:
FROM python:3.8-slim-buster

RUN apt-get update && \
apt-get install -y curl

WORKDIR /app

COPY . .

RUN pip install --no-cache-dir -r requirements.txt

COPY run.sh .

RUN chmod +x run.sh

EXPOSE 8080
CMD ["./run.sh"]
FROM python:3.8-slim-buster

RUN apt-get update && \
apt-get install -y curl

WORKDIR /app

COPY . .

RUN pip install --no-cache-dir -r requirements.txt

COPY run.sh .

RUN chmod +x run.sh

EXPOSE 8080
CMD ["./run.sh"]
now add another file in that same directory with the dockerfile and name it run.sh this is the code inside the run.sh:
#!/bin/sh

uvicorn main:app --host 0.0.0.0 --port 8080 &

sleep 5

python to_dropbox.py
#!/bin/sh

uvicorn main:app --host 0.0.0.0 --port 8080 &

sleep 5

python to_dropbox.py
what this does basically is the same as the CMD statement, but doing it subsequently instead of together
mayank31
mayank31OPβ€’2y ago
oh got it i think it should work let me try and update you so basically you are starting uvicorn first and once it starts then you start the other script in the background right?
Jer
Jerβ€’2y ago
that's right by the way, if it still doesnt work, you can try putting the sleep statement to a longer time, to wait the server to start fully
mayank31
mayank31OPβ€’2y ago
it seems to work thanks! just one more thing i have purchased the developer plan how do i upgrade ram? @JerZ I think you guys upgrade it automatically right? based on the number of requests and current usage
Jer
Jerβ€’2y ago
yes, your cpu, ram, and all other upgrades are automatically upgraded to your project
mayank31
mayank31OPβ€’2y ago
so i have no option to set the maximum for let's say 4 gb i mean it is fine even if it is not there but i guess having such would be great as we can do horizontal scaling after let's say a certain amount of resources by the way @JerZ thanks for your immediate responses
Jer
Jerβ€’2y ago
I believe not, but if I'm not mistaken you can set a maximum limit of credits to your usage np, I don't touch grass sorry wrong info, the devs are currently working on a feature called "relative billing", which allows you to implement project spend limits. This feature should be available in June
mayank31
mayank31OPβ€’2y ago
πŸ‘πŸ»
Adam
Adamβ€’2y ago
this isn’t true, unless you know something I don’t
Jer
Jerβ€’2y ago
Bro I received an email about a changelog that says that
Jer
Jerβ€’2y ago
Railway
Changelog #0133
Fullscreen Logs, Relative Billing, Nixpacks 2.0 RFC
Jer
Jerβ€’2y ago
Adam
Adamβ€’2y ago
project spend limits aren't being released in June. They're planned, but it's nowhere near ready The billing cycle change started today. That's it
Jer
Jerβ€’2y ago
understood, thank you for bringing this to my attention
mayank31
mayank31OPβ€’16mo ago
hey can i disturb you once more? Is there a way to get approximate geolocation? just need country
Brody
Brodyβ€’16mo ago
geo location for what? a user or your service?
mayank31
mayank31OPβ€’16mo ago
for user πŸ™‚
Brody
Brodyβ€’16mo ago
ah, there are various api services that provide you with a geo location for a given IP, but I would recommend against that because an external call to get a user location adds a good amount of extra latency to the end users request. (assuming you are wanting to get the location before a response is returned to the user) what I would recommend is have your code download the maxmind free database, and use a maxmind library to get the location of an IP from looking it up in the local database. (use this method if you need to get the location before returning data to the user, but if getting the location of a user is a background task, the first method is fine)
mayank31
mayank31OPβ€’16mo ago
yeah i downloaded a dataset and using that just wanted to know if there is a better way
Brody
Brodyβ€’16mo ago
using the local maxmind database definitely is the most efficient way possible
mayank31
mayank31OPβ€’16mo ago
actually i am a ml guy but doing frontend and backend for my appπŸ˜…
Brody
Brodyβ€’16mo ago
some tips, you would need to trust the proxy, since the request ip would be coming from a railway proxy and not the end user. have your code download the database to a volume, and only download it if it doesn't exist or is X amount of days out of date, that way you won't have to redownload it on every deployment
mayank31
mayank31OPβ€’16mo ago
i set --forwarded-allow-ips='*' and then get host not sure i am just testing if it works you are right. i just need to get the location once so i can show the pricing according to that. it is very tiring i have got 500+ downloads for my app, i just released a week ago but alone it is very difficult sometimes i wish i hadn't started or i just sell it by the way your knowledge regarding deployments and backend seems really good
Brody
Brodyβ€’16mo ago
thank you, I've been helping around this server for a while now, and I used to manage servers for a small company, so I know a few things lol
mayank31
mayank31OPβ€’16mo ago
is it possible to connect with you on linkedin, only if you are okay. I won't message you with my problems there, i promise only here πŸ™‚
Brody
Brodyβ€’16mo ago
i dont have a linkedin
mayank31
mayank31OPβ€’16mo ago
oh no worries then and thanks again friend! this is the app not sure it would work in your country haven't open worldwide but this is what i was working on https://play.google.com/store/apps/details?id=com.aispeak.version1
AISpeak - Apps on Google Play
Supercharge your IELTS practice and elevate your English language proficiency
Brody
Brodyβ€’16mo ago
lol wat
mayank31
mayank31OPβ€’16mo ago
oh it is just a word i don't promote it πŸ™‚
Brody
Brodyβ€’16mo ago
i know the word but thats dark lol ik ik its just funny
mayank31
mayank31OPβ€’16mo ago
was tired of working for companies so thought let me try something for myself
Brody
Brodyβ€’16mo ago
hell yeah, i like the idea a lot
mayank31
mayank31OPβ€’16mo ago
thanks! it is just i am alone. yeah i felt it has potential thanks for your help. see you later
Brody
Brodyβ€’16mo ago
cya later, if you have any more questions feel free to ask πŸ™‚
mayank31
mayank31OPβ€’14mo ago
hi sorry to disturb again just a quick question can i have multiple projects in hobby plan if yes can each project have 8 gb ram?
Brody
Brodyβ€’14mo ago
yes and yes
Want results from more Discord servers?
Add your server