在Win10上发布Meteor应用

来源:互联网 发布:安卓java模拟器apk 编辑:程序博客网 时间:2024/05/28 11:49

在Win10发布绿色版Meteor应用,发布成功后用户不需要安装Node、Mongodb、Meteor等软件,解压缩就可以运行Meteor应用。
基本思路就是通过demeteorizer打包Meteor应用,然后通过npm install安装好依赖的NPM包,最后把所需要的exe和dll文件打包在一起,形成一个解压即可运行的Meteor应用压缩包。

环境依赖

  • Windows 10
  • Visual Studio 2012
  • Python x64 v2.7
  • Node v0.10.40 x64
  • demeteorizer(“npm install -g demeteorizer”)
  • Meteor for Windows
  • MongoDB x64 v3.2.6

发布过程

  1. 进入需要发布的Meteor应用目录,确认应用能够正常运行
  2. 打开Developer Command Prompt VS2012,进入需要发布的Meteor应用目录运行demeteorizer
  3. 进入.demeteorizer目录,执行npm install --registry=https://registry.npm.taobao.org --disturl=https://npm.taobao.org/dist
  4. 执行npm uninstall bcrypt && npm install bcrypt --registry=https://registry.npm.taobao.org
  5. 新建一个目录,目录名为应用名,目录结构如下:
  6. 6.
    -/bin    --node.exe    --mongod.exe    --libeay32.dll    --ssleay32.dll    --run64.cmd    -/resources    --/data    --/bundle    ---/server    ---/programs    ---main.js

bin目录下的exe和DLL文件从Node、MongoDB的安装目录下拷贝,run64.cmd是程序启动脚本,下面会给出一个模板。
resources目录由.demeteorizer目录拷贝重命名而来,/data目录是新建目录,用来存储应用数据库。

启动脚本模板

@ECHO off:: Basic bathc file to run a meteor app including mongod:: Set some common variablesSETLOCAL ENABLEEXTENSIONSSET me=%~n0SET parent=%~dp0:: Step 1 -- Launch mongod since this needs to be running of courseSET MONGODATA=..\resources\data\dbfolderSET MONGOPORT=20172SET MONGOIP=127.0.0.1mkdir %MONGODATA%echo %me% - Launching Mongo @ %MONGOIP%:%MONGOPORT% Data dir @ %MONGODATA%START /b %parent%/mongod --nohttpinterface --smallfiles --bind_ip %MONGOIP% --port %MONGOPORT% --dbpath %MONGODATA%TIMEOUT /t 5 /NOBREAKclsecho launch jubo:: Now launch our applicationSET MONGO_URL=mongodb://%MONGOIP%:%MONGOPORT%/juboSET PORT=8080SET ROOT_URL=http://localhost:%PORT%/cd ..\resources\bundle%parent%/node main.js

扩展

  • 如果Meteor应用需要设置启动参数,那么可以在启动脚本中通过set METEOR_SETTINGS来设置。
  • 发布成功后,再结合node-webkit就可以发布Windows下Meteor本地应用了。
0 0
原创粉丝点击