Deploy Meteor on Windows

风流意气都作罢 提交于 2019-12-02 23:45:27
sjmcdowall

Predrag -- I started to write up what I hope is going to be a fairly reasonable step-by-step guide on the Meteor Forums here: Windows Deployment.

Hopefully over the next few days I'll complete it, but it's a start!

Meanwhile here are the basic steps for those who don't need a step-by-step guide:

  • On some Windows machine (can certainly be your development machine if you are developing on Windows) make sure to have the following installed:

    1. Meteor
    2. VS12 (VS15 maybe able to work, but I am using VS12) with the c++ command line build tools installed!
    3. Node (if you are tricky can be the same node as is embedded in Meteor) otherwise any node should work
    4. npm
    5. demeteorizer (npm install -g demeteorizer)
  • Then from your Meteor project run the following:

    demeteorizer -o c:\somepath
    cd c:\somepath\bundle\programs\server
    npm install
    

This is the critical part. The last command will attempt to build Fibers .. so make sure the VS command line tools can be found and work.

If the above works, you are almost home!

Running To run the application -- it IS very similar to any other node application except we need to define (at a minimum) two environment variables (the first two below). I do this via a .bat file, but whatever equivalent should be able to work. The ENV variables are defined in the README file under the bundle directory above BTW if you want to read about them.

set MONGO_URL=mongodb://localhost:27017/mydbname
set ROOT_URL=http://myapp.example.com:8080
set PORT=8080
set MAIL_URL=smtp://user:password@host:port
node main.js

Now the above assumes many simplistic things, namely that your are running your MongoDB on the local machine, with no user security, at the default port. If not, you'll need to change the MONGO_URL part to reflect reality. The "mydbname" is whatever logical name you want to call your collection of documents. In Development mode this was "meteor" but it's unlikely that makes much sense in production (especially if it's against a real production DB!). This also assumes NO Oplog Tailing.

I like to specify the PORT explicitly in the .bat file so it's clear and of course needs to be done unless you want to use 3000 (or 80 - whatever the default is, which I don't remember).

You may also have to set the MAIL_URL if you are using any of the user packages that does email notification, etc. I put it above but it's optional.

Anyway, that's the basics. For more details please read the guide linked above (which is a work in progress).

Well, their page about custom deployment is quite short and I discovered some facts while managing to deploy the Welcome to Meteor application:

  • the ROOT_URL environment variable is required but seems that the port number inside makes no sense.
  • the port number is defined by the PORT environment variable or assigned by node. This PORT variable is not mentioned in the guide. I used the netstat command to find out the port used.
  • the MONGO_URL environment variable is optional in this application.
  • must run npm install before executing the meteor build

Hope this help.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!