javascript - 使用Python脚本的Heroku Node.js

标签 javascript python node.js heroku

我在Heroku上运行了一个Node.js应用程序。我在其中添加了一些代码,以使其使用node-cmd运行Python(python3)脚本。所有这些都在本地工作。当我尝试将其部署到Heroku时,构建成功,但是应用程序未加载-应用程序错误提示:“应用程序中发生错误,无法为您的页面提供服务。如果您是应用程序所有者,请检查您的日志有关详细信息。”

我已经添加了Heroku和Node.js buildpacks:

heroku buildpacks:add heroku/python
heroku buildpacks:add heroku/nodejs


我的Procfile看起来像这样:

web: pip3 install -r requirements.txt & npm start


这是控制台输出:

Counting objects: 8, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 925 bytes | 0 bytes/s, done.
Total 8 (delta 4), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Node.js app detected
remote: 
remote: -----> Creating runtime environment
remote:        
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NPM_CONFIG_PRODUCTION=true
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote: 
remote: -----> Installing binaries
remote:        engines.node (package.json):  unspecified
remote:        engines.npm (package.json):   unspecified (use default)
remote:        engines.yarn (package.json):  unspecified (use default)
remote:        
remote:        Resolving node version 6.x...
remote:        Downloading and installing node 6.11.1...
remote:        Using default npm version: 3.10.10
remote:        Resolving yarn version (latest)...
remote:        Downloading and installing yarn (0.28.1)...
remote:        Installed yarn 0.28.1
remote: 
remote: -----> Restoring cache
remote:        Loading 2 from cacheDirectories (default):
remote:        - node_modules
remote:        - bower_components (not cached - skipping)
remote: 
remote: -----> Building dependencies
remote:        Installing node modules (yarn.lock)
remote:        yarn install v0.28.1
remote:        [1/4] Resolving packages...
remote:        [2/4] Fetching packages...
remote:        [3/4] Linking dependencies...
remote:        [4/4] Building fresh packages...
remote:        success Saved lockfile.
remote:        Done in 4.95s.
remote: 
remote: -----> Caching build
remote:        Clearing previous node cache
remote:        Saving 2 cacheDirectories (default):
remote:        - node_modules
remote:        - bower_components (nothing to cache)
remote: 
remote: -----> Build succeeded!
remote: -----> Python app detected
remote: -----> Installing python-3.6.2
remote: -----> Installing pip
remote: -----> Installing requirements with pip


[安装程序包]

remote:        Successfully installed Keras-2.0.6 Markdown-2.6.8 PyMySQL-0.7.11 PyYAML-3.12 SQLAlchemy-1.1.12 Theano-0.9.0 Werkzeug-0.12.2 backports.weakref-1.0rc1 bleach-1.5.0 configparser-3.5.0 h5py-2.7.0 html5lib-0.9999999 mysqlclient-1.3.10 numpy-1.13.1 pandas-0.20.3 protobuf-3.3.0 python-dateutil-2.6.1 pytz-2017.2 scikit-learn-0.18.2 scipy-0.19.1 six-1.10.0 sklearn-0.0 tensorflow-1.2.1
remote: 
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote: 
remote: -----> Compressing...
remote:        Done: 235.4M
remote: -----> Launching...
remote:        Released v17
remote:        https://fathomless-temple-41546.herokuapp.com/ deployed to Herok
remote: 
remote: Verifying deploy... done.
To https://git.heroku.com/fathomless-temple-41546.git
   3ed0799..e16fb12  master -> master


有什么我想念的吗?

最佳答案

heroku buildpacks:add heroku/python
heroku buildpacks:add heroku/nodejs
heroku ps:scale web=1


我得到一个Scaling dynos... ! ▸ Couldn't find that process type (web).
运行scale web=1时发生错误,我通过使用web: bundle exec node app -p $PORT临时添加Procfile并在从应用程序中删除Procfile之前再次运行它来解决此问题。

关于javascript - 使用Python脚本的Heroku Node.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45392435/

相关文章:

node.js - 为什么不能向 fork 子流程发送多于消息(字符串)的内容?

javascript - promise Socket.IO/EventEmitter

javascript - 处理来自 REST API 的客户端错误

javascript - jQuery 父级然后找到要隐藏的 div

Javascript onclick 附件索引器问题

python - 为什么带有 S3Boto 后端的 django-storages 的 default_storate.exists() 会导致大型 S3 存储桶出现内存错误?

python - 'DataFrame' 对象没有属性 'sort'

python - 如何查找附加到一个或另一个类的元素? Selenium python

node.js - 如何在node.js中创建带有书签和内部链接的pdf文档

javascript - 如何在 Highcharts 中为堆积图的图例创建表格?