R
Railwayโ€ข15mo ago
Faolain

Litestar command not found

Hey all apologies for the possibly silly question. I am looking to deploy this repo: https://github.com/Faolain/mypy-monorepo specifically what is within the packages/backend folder which is a python litestar(https://github.com/litestar-org/litestar) application (a web framework like flask/django/fastapi) but I'm running into an issue where the build log appears to be fine but the deploy log states /bin/bash: line 1: litestar: command not found (wherein litestar is the start command).
This monorepo is a slight modification of this very same repo https://railway.app/template/KmHMvQ (just instead I have setup mine within a monorepo) however even when I tried to deploy this original template as is, I also see the /bin/bash: line 1: litestar: command not found issue. I was wondering what could be wrong and how this could be fixed? For reference running this start command locally does work within the folder.
GitHub
GitHub - Faolain/mypy-monorepo
Contribute to Faolain/mypy-monorepo development by creating an account on GitHub.
GitHub
GitHub - litestar-org/litestar: Light, Flexible and Extensible ASGI...
Light, Flexible and Extensible ASGI API framework | Effortlessly Build Performant APIs - GitHub - litestar-org/litestar: Light, Flexible and Extensible ASGI API framework | Effortlessly Build Perfo...
Solution:
so wanna try passing 2 as the number of workers to --http-workers? you can just edit the start command in the nixpacks.toml file!
Jump to solution
97 Replies
Percy
Percyโ€ข15mo ago
Project ID: a9d07b8e-7f49-495c-83b4-81779c722734
Faolain
Faolainโ€ข15mo ago
a9d07b8e-7f49-495c-83b4-81779c722734
Brody
Brodyโ€ข15mo ago
does that template you linked even work?
Faolain
Faolainโ€ข15mo ago
It does not appear to but I am unable to confirm if it is experiencing the same litestar command not found error since the deploy logs tab stays loading but never displays the error (for that template) https://railway.app/project/cc97006c-2dc9-422d-9c8f-2ec9fff36fd3/service/119bc432-d70b-4f31-b886-24f2c5f89e86?id=830780ed-31ed-4506-b666-4ccbe62e1f4e
Brody
Brodyโ€ข15mo ago
you are not able to view logs for a public project please try deploying that template yourself
Faolain
Faolainโ€ข15mo ago
yes I tried doing that already (deploying the template myself) and got the same Litestar command not found seen on the monorepo application as well (in the initial message) which is why I expect the original template has that issue too
Brody
Brodyโ€ข15mo ago
yeah it appears like that template creator did not know what they are doing, theres nothing wrong with that, but they shouldn't have published the template if they didnt know what they where doing
Faolain
Faolainโ€ข15mo ago
ah that's okay, any suggestions on how to solve the error re: command not being found?
Brody
Brodyโ€ข15mo ago
and i don't either, so i will have to do some research and get back to you on this, hopefully with a working litestar example
Faolain
Faolainโ€ข15mo ago
really appreciate it
Faolain
Faolainโ€ข15mo ago
If it's helpful their most up-to-date e2e example repo is here https://github.com/litestar-org/litestar-fullstack
GitHub
GitHub - litestar-org/litestar-fullstack: Litestar Fullstack Refere...
Litestar Fullstack Reference Application with Vue, Vite, and SQLAlchemy, Docker, Task Queues, and more! - GitHub - litestar-org/litestar-fullstack: Litestar Fullstack Reference Application with Vue...
Brody
Brodyโ€ข15mo ago
will see what i can do, no promises, im not even a python dev
Faolain
Faolainโ€ข15mo ago
if you need any assistance lmk!
Brody
Brodyโ€ข15mo ago
haha you came here for assistance
Faolain
Faolainโ€ข15mo ago
always down to help someone help me ๐Ÿ˜… , I can maybe message someone from the litestar team to also give a look if you need help as well.
Brody
Brodyโ€ข15mo ago
so do you prefer pyproject.toml over a requirements.txt file?
Faolain
Faolainโ€ข15mo ago
correct (preferring pyproject.toml)
Brody
Brodyโ€ข15mo ago
it deploys just fine, but please tell me if ive done something wrong https://railway.app/template/Chc5nL
Faolain
Faolainโ€ข15mo ago
Really appreciate it Brody, amazing turnaround. Will send to litestar team, looking at the repo now seems like there have been some pretty significant changes/removals. Are those all necessary or is it just the nixpacks.toml, railway.json, and the .env changes?
Brody
Brodyโ€ข15mo ago
are you associated with the litestar team?
looking at the repo now seems like there have been some pretty significant changes/removals
yeah, there was too much junk
Faolain
Faolainโ€ข15mo ago
I am not but active in their discord, and looking to contribute where I can as it seems like one of the most promising python frameworks with an extremely active developer community
Brody
Brodyโ€ข15mo ago
well they probably wont like that i called some stuff in the repo junk lol repo was just too cluttered imo
Faolain
Faolainโ€ข15mo ago
fair enough, I think the fullstack starter repo there is so that anyone can get setup in an opinionated fashion, to setup a production app. (for example the github actions, vscode settings for localized optimal development, among other commands) In any case last question while I get familiarized with this setup, really appreciate it all again, was just wondering how railway knows to setup redis or postgres? I see that railway doesn't support docker-compose yet and was under the impression it was originally doing that
Brody
Brodyโ€ข15mo ago
ah I just clicked the postgres and redis options while making the template then railway will auto add the reference variables to the service when you deploy the template
Faolain
Faolainโ€ข15mo ago
hmm I see, appreciate it brody! The only reason I ask is that it seemed a bit like "magic" wherein I thought it would be a bit more declarative looking at the codebase, railway would "know" what services to deploy as is, without template interaction. Along these lines in the original litestar template they have a worker also deploy alongside via docker-compose. Is there any suggested way to do this with railway?
Brody
Brodyโ€ข15mo ago
yeah I used run-all, but if you wanted another service you just make another service and update the start command accordingly question for you now, did I remove anything crucial to the apps functionality?
Faolain
Faolainโ€ข15mo ago
Not that I'm aware of, just poking around at the moment! Really great stuff here ๐Ÿ™‚ fwiw this repo is sort of like the reference repo where litestar apps are deployed so if this is done correctly then it's likely to get pushed upstream and lead to a lot of litestar app deployments on railway (good for both) Ah yeah was just gonna type that I saw you made it a run-all in order to group both. Sorry for being annoying just getting familiarized, are there any plans to make the service creation (or maybe already exists) more declarative via code itself? The equivalent to a docker-compose
Brody
Brodyโ€ข15mo ago
also, it used a lot of memory? is that normal?
Faolain
Faolainโ€ข15mo ago
how much memory?
Brody
Brodyโ€ข15mo ago
railway wants to support docker compose at some point, but it's complicated, and as far as I know none of the other top railway competitors support docker compose either until railway supports it, template creators will just deconstruct the compose file and manually translate it into railway services
Faolain
Faolainโ€ข15mo ago
Yeah gotcha just having something whether it's docker compose or something else (though ofc docker-compose is preferable due to cross-compatibility and support to deploy outside of PaaS) removes some of the "magic" in setup and makes things a bit more expected/auomated in deployments yep fair enough! btw happen to have a number on this?
Brody
Brodyโ€ข15mo ago
let me check 2.98gb
Faolain
Faolainโ€ข15mo ago
that seems extremely high/out of the ordinary, this is on the litestar service itself that you deployed as is?
Brody
Brodyโ€ข15mo ago
well its not as is, I did remove a bunch of stuff, and added the nixpacks.toml and railway.json file you've read both those config files right?
Faolain
Faolainโ€ข15mo ago
yep!
Brody
Brodyโ€ข15mo ago
I'm not doing anything out of the ordinary right?
Faolain
Faolainโ€ข15mo ago
not that I can see at face value no I will dig in a bit more on this tomorrow/ask the litestar team as well if this is normal
Brody
Brodyโ€ข15mo ago
and I'm just doing a run-all with a host and port so railway can proxy to it
Faolain
Faolainโ€ข15mo ago
really really appreciate all this again!
Brody
Brodyโ€ข15mo ago
thank you, I can't publish this template as it stands if it uses 3gb of memory lol that's 30$
Faolain
Faolainโ€ข15mo ago
understood
Brody
Brodyโ€ข15mo ago
have you tried running litestar run-all locally? because I haven't ran litestar locally at all, curious to see how much ram it uses locally
Faolain
Faolainโ€ข15mo ago
Just ran it locally ~100-200mb, do you happen to see anything going on in the logging? / do you see an increase in memory usage over time which could indicate a memory leak?
Bad Messages
Bad Messagesโ€ข15mo ago
Following
Brody
Brodyโ€ข15mo ago
will do some testing later tonight, I'm away from the computer for today
Faolain
Faolainโ€ข15mo ago
Thanks Brody!
Faolain
Faolainโ€ข15mo ago
Can confirm I launched the same template and see ~3gb of memory usage
Faolain
Faolainโ€ข15mo ago
Brody
Brodyโ€ข15mo ago
I wasn't able to test locally yesterday, was out all day if you have any ideas why that could be so high I'm all ears
Faolain
Faolainโ€ข15mo ago
@Coffee anything come to mind here?
Brody
Brodyโ€ข15mo ago
that's a lot of workers?
Bad Messages
Bad Messagesโ€ข15mo ago
Be default the worker count is equal to the number of cores available iirc.. you maybe want to pass 1-2 instead. https://github.com/litestar-org/litestar-fullstack/blob/0ef30d73d4c5622ce2da94b882ba82935b0c284e/src/app/cli.py#L87-L94
GitHub
litestar-fullstack/src/app/cli.py at 0ef30d73d4c5622ce2da94b882ba82...
Litestar Fullstack Reference Application with Vue, Vite, and SQLAlchemy, Docker, Task Queues, and more! - litestar-org/litestar-fullstack
Brody
Brodyโ€ข15mo ago
that function may actually return 33 https://utilities.up.railway.app/stats note: I am not on the pro plan
Faolain
Faolainโ€ข15mo ago
and there are indeed 33 'Started server process logs in the deploy logs (also on the hobby plan not pro) So I guess @Brody multiprocessing.cpu_count() returns 32 on railway? (even for hobby instances)
Faolain
Faolainโ€ข15mo ago
Brody
Brodyโ€ข15mo ago
indeed it would, that's why railway calls it vcpu and not vcores but of course your app would get a sigterm if it tried to use more resources than allowed
Solution
Brody
Brodyโ€ข15mo ago
so wanna try passing 2 as the number of workers to --http-workers? you can just edit the start command in the nixpacks.toml file!
Faolain
Faolainโ€ข15mo ago
maybe this could be made clearer on the railway docs page? as it seems from hobby only 8 are available (and both of our accounts are on hobby but it's seemingly using 32 no?) doing so now, however I think you mean railway.json right? (Since that's what has the start command)
Faolain
Faolainโ€ข15mo ago
Faolain
Faolainโ€ข15mo ago
looks like that did it ๐Ÿ™‚
Brody
Brodyโ€ข15mo ago
while my code can see 32 vcpus, I would not be able to use more than 8 vcpu without my app getting killed, prompting me to upgrade to pro yeah my bad, did mean railway.json so 309mb is acceptable, correct?
Faolain
Faolainโ€ข15mo ago
yep far more normal! haha interesting so if it were launched as such what would trigger/prompt the killing? is there any way railway can make this more obvious to the end user? Since it seems at face value only 8vcpu would ever be available just from the hobby plan page
Brody
Brodyโ€ข15mo ago
I really don't know why my app can see 32vcpu and well over 250gb of ram, I was just surprised as you are, and I'm sure some kind of docker deamon would watch for and kill any containers that use more resources than their plan allows
Faolain
Faolainโ€ข15mo ago
amazing detective work nevertheless, maybe something to pass along to the rest of the team? Probably can trip up other noobies who are onboarding onto railway
Brody
Brodyโ€ข15mo ago
I asked the team directly in our chat, I will let you know what they say if they get back to me
Faolain
Faolainโ€ข15mo ago
appreciate it thanks so much again for everything Brody!
Brody
Brodyโ€ข15mo ago
no problem, I would have never come to a solution if coffee didn't send that code snippet!! I mean coffee said the solution, I just said why so many threads spawn lol
Faolain
Faolainโ€ข15mo ago
well you did after all create the nixpacks template in order to get it launched in the first place! would have never got to that point without it. But yeah I can imagine this won't be just a litestar thing, good for railway to know I guess to prevent overprovisioning of instances see how great the litestar team is (I promise not being paid to shill haha)
Brody
Brodyโ€ข15mo ago
so would you two say that the template is public ready? and should I add back the stuff I removed?
Faolain
Faolainโ€ข15mo ago
I think adding back the stuff removed would be good, I think the community/litestar team could also update the repo upstream so that new devs can quickly get started also deploying an app on the "free" hobby instance
Brody
Brodyโ€ข15mo ago
will do, i will rebase my repo and add only the stuff needed to get it running on railway
Faolain
Faolainโ€ข15mo ago
amazing thanks so much Brody, maybe you can make a PR as well upstream too once you do?
Brody
Brodyโ€ข15mo ago
if thats something the litestar team would be interested in, i can for sure do that
Faolain
Faolainโ€ข15mo ago
just figured if it was already done why not make the PR but figure up to you haha
Brody
Brodyโ€ข15mo ago
will do! ill have to ask fp to remove the current litestar template as its now clear to us they made no attempt to run the template on railway wait Jacob Coffee = @Coffee ?? @Coffee would you be interested in removing your templates for now until your base repo supports deploying directly to railway?
Bad Messages
Bad Messagesโ€ข15mo ago
templates plural? What do you mean directly, sorry. afaik both templates have base repos with railway deployment in mind
Brody
Brodyโ€ข15mo ago
neither of these templates will deploy
Brody
Brodyโ€ข15mo ago
their repo lacks a proper build plan, and most of your template variables are incorrect/not ideal
Brody
Brodyโ€ข15mo ago
specifically the DB_URL and REDIS_URL variables
Brody
Brodyโ€ข15mo ago
using app.gov is also not the best idea, you should let the user fill those kinds of variables out themselves LitestarRocks! as the secret key is not ideal either, you should use the ${{secret()}} template function https://docs.railway.app/reference/templates#template-variable-functions
Bad Messages
Bad Messagesโ€ข15mo ago
Sorry ๐Ÿ˜ฌ I don't think I am following on the build plan What do you mean dont deploy? I deployed the Litestar w/ Tailwind one without issue (https://litestar-production-872f.up.railway.app/) https://railway.app/project/f126396d-42ac-4fea-90d4-5ad2e27a027a/service/ffc06993-a0d9-48c6-99bd-fd2a4092b65b I know the Fullstack one has the issue of requiring users to change the url vars to match the service urls of the railway-deployed redis/postgres instances, but I wasnt 100% sure if there was a dynamic way to do this to me build plan means adding the railway.json, but I am still learning this system/nixpacks/etc. so happy to do whatever you recommend
Brody
Brodyโ€ข15mo ago
okay let me ask you this, have you tried to deploy your litestar fullstack template? if you have, it wouldnt work https://discord.com/channels/713503345364697088/1144691393357434980/1144698950583070862 this file is required to build the fullstack litestar app https://github.com/brody192/litestar-fullstack-template/blob/main/nixpacks.toml would you mind taking down your fullstack template in favor of my template? i would set everything up properly with the dynamic database variables
Bad Messages
Bad Messagesโ€ข15mo ago
ohh i see neat Sure, could you use the same template overview i have? just want to make sure i give credit to the original author before it was transfered into our org repo and we have the project links and usch
Brody
Brodyโ€ข15mo ago
of course, id only add the stuff required to run it on railway you would accept a pr for this nixpacks stuff right?
Bad Messages
Bad Messagesโ€ข15mo ago
Well We actually have an open issue to add native railway support, but i'd like to instead move from my personal repo to the newly-transfered-into-org litestar-fullstack repo
Bad Messages
Bad Messagesโ€ข15mo ago
GitHub
Enhancement: Deployment Guide for Railway ยท Issue #58 ยท litestar-or...
Summary Deployment Guide for Railway Basic Example No response Drawbacks and Impact No response Unresolved questions No response
Bad Messages
Bad Messagesโ€ข15mo ago
So yes in that repo, we could just do all of that and then write some docs (optionally for you, or we could later idc)
Brody
Brodyโ€ข15mo ago
you just give me a link to the base repo and ill pr it ๐Ÿ‘
Bad Messages
Bad Messagesโ€ข15mo ago
GitHub
GitHub - litestar-org/litestar-fullstack: Litestar Fullstack Refere...
Litestar Fullstack Reference Application with Vue, Vite, and SQLAlchemy, Docker, Task Queues, and more! - GitHub - litestar-org/litestar-fullstack: Litestar Fullstack Reference Application with Vue...
Brody
Brodyโ€ข15mo ago
great, after my pr gets merged, i will create a template from that repo instead of my own repo also, are you aware you are displaying the vue logo for both vite and vue links? https://github.com/litestar-org/litestar-fullstack/blob/main/src/app/domain/web/resources/App.vue#L8-L11
Bad Messages
Bad Messagesโ€ข15mo ago
I think he is yes
Faolain
Faolainโ€ข15mo ago
amazing!
Brody
Brodyโ€ข15mo ago
@Coffee https://github.com/litestar-org/litestar-fullstack/pull/67 let me know if i did anything wrong lol
Faolain
Faolainโ€ข14mo ago
Brody do you happen to have this template available somewhere? Looks like the link is now dead
Faolain
Faolainโ€ข14mo ago
thank you
Brody
Brodyโ€ข14mo ago
no problem
Want results from more Discord servers?
Add your server