在生产中将Docpad部署到模数

时间:2013-11-03 05:31:26

标签: json node.js deployment coffeescript docpad

我想知道如何将docpad项目部署到modulus

假设我需要在生产模式下运行才能这样做。我注意到在docpad上进行静态部署只需上传out目录的内容。如果我们使用节点服务器,我们上传整个项目目录。我尝试了但我不认为我的docpad.coffee设置是正确的。你可以在下面看到我的尝试。

docpad.coffee

    # ----------------
    # Server Configuration
    # Server Express
    # ----------------
    # The express.js instance that we want DocPad to use
    # If not set, we will create our own
    serverExpress: default



    # ----------------
    # Port
    # ----------------
    # Use to change the port that DocPad listens to
    # By default we will detect the appropriate port number for our environment
    # if no environment port number is detected we will use 9778 as the port number
    # Checked environment variables are:
    # - PORT - Heroku, Nodejitsu, Custom
    # - VCAP_APP_PORT - AppFog
    # - VMC_APP_PORT - CloudFoundry
    port: - PORT

根据模数站点的第一步是使用环境变量PORT。 app.listen(process.env.PORT)我认为这意味着将- PORT添加到 docpad.coffee 文件中。

我甚至不确定如何在上传时让网站在生产中运行,请记住我只是上传整个目录。部署项目后,我是否在终端的Modulus服务器上运行命令?

Modulus还在packages.json文件中询问以下内容。除了我假设的"main": "path/to/custom_main.js"是docpad.coffee文件之外,我已经有了大部分内容,所以我链接到了它。

的package.json

    {
  "name": "zurb-foundation.docpad",
  "version": "0.4.0",
  "description": "Zurb Foundation skeleton for DocPad. Simple and flexible HTML, CSS, and Javascript for popular user interface components and interactions.",
  "homepage": "https://github.com/axyz/zurb-foundation.docpad",
  "keywords": [
    "docpad-skeleton",
    "docpad",
    "website",
    "foundation",
    "zurb foundation"
  ],
  "author": "Andrea Moretti <axyzxp@gmail.com>",
  "maintainers": [
    "Andrea Moretti <axyzxp@gmail.com>"
  ],
  "contributors": [
    "Andrea Moretti <axyzxp@gmail.com>"
  ],
  "bugs": {
    "url": "https://github.com/axyz/zurb-foundation.docpad/issues"
  },
  "repository": {
    "type": "git",
    "url": "http://github.com/axyz/zurb-foundation.docpad.git"
  },
  "engines": {
    "node": "0.10",
    "npm": "1.3"
  },
  "main": "docpad.coffee",
  "dependencies": {
    "docpad": "~6.54.1",
    "docpad-plugin-eco": "~2.0.2",
    "docpad-plugin-livereload": "~2.5.3",
    "docpad-plugin-coffeescript": "~2.2.2",
    "express" : "2.5.x",
    "ejs" : "0.8.x",
    "docpad-plugin-nodesass": "~2.1.1"
  },
  "main": "node_modules/docpad/bin/docpad-server",
  "scripts": {
    "start": "node_modules/docpad/bin/docpad-server"
  },
  "devDependencies": {}
}

当我部署网站时它根本不起作用,我的意思是我有一个链接,但网站没有工作。有关将docpad站点部署到Modulus时该怎么做的任何建议?我在安装docpad之后也使用了带有Sass的骨架基础,它在本地工作。

好的仍然试图让这个东西工作,当我运行网站现在它在本地工作,当我部署它时,我得到一个模块subdomian的链接不起作用。我去检查模数站点上的日志,这就是我得到的

模数日志

...

docpad-plugin-coffeescript@2.2.2 node_modules/docpad-plugin-coffeescript
└── coffee-script@1.6.3

docpad-plugin-eco@2.0.2 node_modules/docpad-plugin-eco
└── eco@1.1.0-rc-3 (strscan@1.0.1, coffee-script@1.6.3)

express@2.5.11 node_modules/express
├── qs@0.4.2
├── mime@1.2.4
├── mkdirp@0.3.0
└── connect@1.9.2 (formidable@1.0.14)

docpad-plugin-livereload@2.5.3 node_modules/docpad-plugin-livereload
├── extendr@2.1.0 (typechecker@2.0.8)
├── primus@1.4.4 (extendable@0.0.6, load@1.0.0)
└── ws@0.4.31 (tinycolor@0.0.1, options@0.0.5, commander@0.6.1, nan@0.3.2)

docpad@6.54.4 node_modules/docpad
├── lazy-require@1.0.0
├── eachr@2.0.2
├── extendr@2.1.0
├── extract-opts@2.2.0
├── caterpillar-filter@2.0.3
├── envfile@1.0.0
├── getmac@1.0.6
├── commander@2.0.0
├── ambi@2.1.6
├── typechecker@2.0.8
├── taskgroup@3.3.0
├── mime@1.2.11
├── query-engine@1.5.3
├── bal-util@2.3.2
├── safefs@3.0.3 (taskgroup@3.2.4)
├── semver@2.2.1
├── safeps@2.2.8 (taskgroup@3.2.4)
├── caterpillar-human@2.1.1 (ansistyles@0.1.1, ansicolors@0.2.1)
├── progressbar@1.0.3 (progress@1.1.2)
├── event-emitter-grouped@2.3.1 (taskgroup@3.2.4)
├── watchr@2.4.4 (taskgroup@3.2.4)
├── promptly@0.2.0 (read@1.0.5)
├── backbone@1.1.0 (underscore@1.5.2)
├── jschardet@1.1.0
├── superagent@0.15.7 (methods@0.0.1, cookiejar@1.3.0, debug@0.7.3, qs@0.6.5, emitter-component@1.0.0, reduce-component@1.0.1, mime@1.2.5, formidable@1.0.14)
├── lodash@2.2.1
├── cson@1.4.5 (requirefresh@1.1.2, coffee-script@1.6.3, js2coffee@0.2.3)
├── caterpillar@2.0.6 (readable-stream@1.1.9)
├── encoding@0.1.7 (iconv-lite@0.2.11)
├── yamljs@0.1.4 (glob@3.1.21, argparse@0.1.15)
└── express@3.4.4 (methods@0.1.0, range-parser@0.0.4, cookie-signature@1.0.1, fresh@0.2.0, debug@0.7.3, buffer-crc32@0.2.1, cookie@0.1.0, send@0.1.4, mkdirp@0.3.5, commander@1.3.2, connect@2.11.0)

docpad-plugin-nodesass@2.1.1 node_modules/docpad-plugin-nodesass
├── node-neat@1.0.0
├── node-bourbon@1.0.0
├── taskgroup@3.2.4 (ambi@2.1.6)
└── node-sass@0.7.0 (node-watch@0.3.4, colors@0.6.0-1, mkdirp@0.3.5, optimist@0.6.0, mocha@1.13.0)
INFO: Main file specified in package.json: node_modules/docpad/bin/docpad-server
INFO: Starting application.
[32minfo:[39m Welcome to DocPad v6.54.4 (global installation: /mnt/data/2/node_modules/docpad)
[32minfo:[39m Contribute: http://docpad.org/docs/contribute
[32minfo:[39m Plugins: 
[32minfo:[39m Environment: production
[32minfo:[39m DocPad listening to http://localhost:8080/ on directory /mnt/data/2/node_modules/docpad/bin/out
[32minfo:[39m Generating...
[33mnotice:[39m DocPad is currently running without any plugins installed. You probably want to install some: http://docpad.org/plugins
Error: Cannot generate website as the src dir was not found
    at /mnt/data/2/node_modules/docpad/out/lib/docpad.js:3102:21
    at /mnt/data/2/node_modules/docpad/node_modules/safefs/out/lib/safefs.js:185:16
    at Object.cb [as oncomplete] (fs.js:168:19)
[2013-11-03T17:19:32.095Z] Application initialized with pid 69363

可以在此处查看整个日志文件https://gist.github.com/kitsondevelopment/7292623

它说它无法找到src目录但是根据这个屏幕截图来源目录,所以我不明白。

enter image description here

更新

我刚注意到它引用了node_modules / docpad目录中的src目录的错误,我用docpad run创建的应用程序在node_modules / docpad中没有src目录。这可能是什么?

1 个答案:

答案 0 :(得分:1)

<强>更新

当使用package.json将docpad设置为入口点时,模数似乎有些奇怪。我的猜测是它没有正确设置当前目录。

我通过创建app.js来实现它,只需将执行交给docpad(类似于AppFog的deployment instructions

module.exports = require(__dirname+'/node_modules/docpad/out/bin/docpad-server');

然后在package.json中,我将main指向app.js

"engines" : {
    "node": "0.10",
    "npm": "1.2"
},
"dependencies": {
    ... the dependencies from the skeleton ...
},
"main": "app.js",

===

您根本不应设置serverExpress。删除那组线。您也不应该设置port。 docpad.coffee中的port设置仅在您要对特定端口进行硬编码时(您不需要)。 docpad将自动查看节点主机通常使用的所有环境变量(包括Modulus正在设置的环境变量),并在没有做任何特殊操作的情况下找出正确的端口。