meteor icon indicating copy to clipboard operation
meteor copied to clipboard

Document main function

Open zodern opened this issue 3 years ago • 7 comments

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 avatar Nov 24 '22 16:11 zodern

@zodern do you mean, it needs more comments?

bakhtiardev avatar Jan 03 '23 11:01 bakhtiardev

@bakhtiarcr7 I believe he meant adding a new entry here.

harryadel avatar Jan 07 '23 21:01 harryadel

I think there are one or two more things we should be before closing this:

  1. Document how Meteor finds the main function, or how to provide the main function
  2. I'm wondering if we should put the docs for the main function someplace else, maybe in the Core docs. The main function docs are needed if an app doesn't use webapp, so the webapp docs doesn't seem like it would be the easiest place to find it.

zodern avatar Apr 04 '23 15:04 zodern

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 main function from the package to global scope
  • setup an http server using your favorite tool (maybe a minimal fastify example 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?
  • the function may return DAEMON in order to keep the process alive

However, I think this goes way beyond simply defining this main method:

  • browser-policy and routepolicy require webapp and are thus not usable in a custom setup
  • ddp-server depends 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

jankapunkt avatar Oct 05 '23 07:10 jankapunkt

/assign

msudipta888 avatar Oct 12 '24 14:10 msudipta888

lets go for this

ghost avatar Oct 15 '24 18:10 ghost

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.

github-actions[bot] avatar May 26 '25 20:05 github-actions[bot]