我用Sails.js创建了一个简单的应用程序并将其部署到Heroku,它运行正常
这是我的Procfile
:
web: sails lift
但是在Heroku上(我认为)没有安装二进制sails
,所以它是如何工作的?
更新:
如果使用了main
命令,我已从start
删除了package.json
和npm start
个部分,但应用仍然正常运行。
此外,我在Procfile中添加了--prod
选项,并且处理正确。
以下是git push
输出(没有关于Procfile的警告/错误)
-----> Node.js app detected
PRO TIP: Specify a node version in package.json
See https://devcenter.heroku.com/articles/nodejs-support
-----> Defaulting to latest stable node: 0.10.28
-----> Downloading and installing node
-----> Restoring node_modules directory from cache
-----> Pruning cached dependencies not specified in package.json
-----> Writing a custom .npmrc to circumvent npm bugs
-----> Exporting config vars to environment
-----> Installing dependencies
-----> Caching node_modules directory for future builds
-----> Cleaning up node-gyp and npm artifacts
-----> Building runtime environment
-----> Discovering process types
Procfile declares types -> web
-----> Compressing... done, 19.3MB
-----> Launching... done, v8
和heroku logs
(流程以sails lift --prod
命令启动,而不是node app.js
)
Slug compilation started
Slug compilation finished
Deploy 35bcbd9 by ...
Release v8 created by ..
Unidling
State changed from down to starting
Starting process with command `sails lift --prod`
memory, and will not scale past a single process.
Warning: connection.session() MemoryStore is not
designed for a production environment, as it will leak
info: Sails.js <|
info:
info: /|.\
info: v0.9.16 |\
info: `--'-------'
info: / || \
info: .-'.-==|/_--'
info: __---___--___---___--___---___--___
info: ,' |' \
info: To see your app, visit http://localhost:3661
debug: --------------------------------------------------------
info: Server lifted in `/app`
info: ____---___--___---___--___---___--___-__
info:
info: To shut down Sails, press <CTRL> + C at any time.
info:
debug: :: Sat May 17 2014 09:37:00 GMT+0000 (UTC)
debug:
debug: Environment : production
debug: --------------------------------------------------------
debug: Port : 3661
State changed from starting to up
答案 0 :(得分:0)
我的理解是heroku从node_modules获取二进制文件并将它们添加到路径中(或类似的东西。
另一个选择是,你的Procfile可能没有被考虑在内(比如它是错位的或者它有什么问题),那么它将默认为&#34; npm start&#34 ;,这可能在你的包中。 json重定向到节点app.js&#34; (而不是sails二进制)。
在我的情况下,我没有配置文件,它运行正常,但我不知道它是否默认为&#34; npm start&#34;或者是codeship.io(我的构建系统)谁告诉heroku这样做(我没有触及任何配置)。
更新:根据heroku文档(https://devcenter.heroku.com/articles/nodejs-support),
将设置以下环境变量: PATH =供应商/节点/ bin中:BIN:node_modules / .bin作为:$ PATH
node_modules / .bin的东西可以解决这个问题:)