meteor
meteor copied to clipboard
Document main function
Every Meteor app has to have a main function. For most apps, the webapp package defines it. For apps that do not use the webapp package, they have to define it another way, but it currently isn't documented.
The relevant code is: https://github.com/meteor/meteor/blob/1e2346cd5a31a4044afad4049dd736f518d6ea76/tools/static-assets/server/boot.js#L452-L486
@zodern do you mean, it needs more comments?
@bakhtiarcr7 I believe he meant adding a new entry here.
I think there are one or two more things we should be before closing this:
- Document how Meteor finds the main function, or how to provide the main function
- I'm wondering if we should put the docs for the
mainfunction someplace else, maybe in the Core docs. Themainfunction docs are needed if an app doesn't usewebapp, so thewebappdocs doesn't seem like it would be the easiest place to find it.
am I correct that weapp registers the main here:
https://github.com/meteor/meteor/blob/c4b1bad9540aba1f296ccbd6be4e5c9d5f7e5376/packages/webapp/webapp_server.js#L1373-L1451
From what I see there, it looks like the following is minimally required:
- export a
mainfunction from the package to global scope - setup an http server using your favorite tool (maybe a minimal
fastifyexample would be good here?)- respect process env variables:
PORT,METEOR_PRINT_ON_LISTEN,UNIX_SOCKET_PATH,UNIX_SOCKET_PERMISSIONS,UNIX_SOCKET_GROUP(are these set by the tool or require manual setup, looks like this is for running in a cluster, right?) - what else env variables to respect here?
- respect process env variables:
- the function may return
DAEMONin order to keep the process alive
However, I think this goes way beyond simply defining this main method:
browser-policyandroutepolicyrequire webapp and are thus not usable in a custom setupddp-serverdepends on these, too so no DDP in a custom setup either (unless it gets rewritten some day)- a classic Meteor setup is not usable and the usa-case for a Meteor app without
webapp(for example microservices using another tool than ~~connect~~ express)
Edit: if you think this is sufficient for documentation (considering the content above) I would go for it and write some nice docs for this. However I still don't know where to put this in the docs
/assign
lets go for this
This issue has been automatically labeled as idle due to 90 days of inactivity. If this issue is still relevant, please comment to reactivate it.