I need to deploy a node application that isn't in the root of my project.
My project is similar to this: https://github.com/graphql-boilerplates/react-fullstack-graphql/tree/master/advanced
In the root of the project is a React app but I dont want to deploy this. In a folder called “server” there is my node server and this is what I need to deploy to Heroku.
When I deploy Heroku appears to run npm run start on the top level package.json. How can I make Heroku ignore this and just run the package.json in the /server folder?
Update: Ive created a Procfile in my project root with the following:
web: ./server npm run start
But when I deploy I get an application error:
2018-07-05T12:41:51.627168+00:00 app[api]: Release v4 created by user MYEMAIL#gmail.com
2018-07-05T12:41:59.000000+00:00 app[api]: Build succeeded
2018-07-05T12:42:02.176695+00:00 heroku[web.1]: Starting process with command `./server npm run start`
2018-07-05T12:42:04.817337+00:00 heroku[web.1]: State changed from starting to crashed
2018-07-05T12:42:04.701159+00:00 app[web.1]: bash: ./server: Is a directory
2018-07-05T12:42:04.782252+00:00 heroku[web.1]: Process exited with status 126
2018-07-05T12:42:11.974345+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=DEPLOY-NAME.herokuapp.com request_id=c2cba42e-80af-4b16-95sdfdfd-2918 fwd="86.343.251.15" dyno= connect= service= status=503 bytes= protocol=https
Check out heroku-prebuild script. I have an API app and a react app that are both served by Express but in different folders. Put package.json in the root and use heroku-prebuild to move around to other folders.
{
"scripts": {
"heroku-prebuild": "cd app && npm install && npm run build && cd .. && cd api && npm install",
"start": "cd api && npm start"
}
}
If you use buildpacks, this solution is probably the cleaner one.
You just have to use this custom Buildpack :
https://elements.heroku.com/buildpacks/timanovsky/subdir-heroku-buildpack
heroku buildpacks:clear
heroku buildpacks:set https://github.com/timanovsky/subdir-heroku-buildpack
heroku buildpacks:add heroku/nodejs
heroku config:set PROJECT_PATH=projects/nodejs/frontend
Deploy your project to Heroku.
You can change this behaviour by defining a Procfile that overrides start: https://devcenter.heroku.com/articles/nodejs-support#default-web-process-type
Ive messaged Heroku support and they pretty much said they don't support deploying a node app that's not in the project root.
Im going to split my project up but you could probably do it with git subtree.
Related
error H14 happen while deploying to heroku
this is my procfile:
web: gunicorn -w 4 -b 0.0.0.0:$PORT -k gevent main:app
log on heroku:
2017-01-23T10:42:58.904480+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=meetcapstone.herokuapp.com request_id=df88efb5-a81a-4ac0-86dc-4e03d71266bb fwd="81.218.117.137" dyno= connect= service= status=503 bytes=
2017-01-23T10:42:59.009135+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=meetcapstone.herokuapp.com request_id=21cea981-36b0-4410-891f-548bbc29f0ee fwd="81.218.117.137" dyno= connect= service= status=503 bytes=
requirements:
Flask==0.11.1
passlib==1.7.0
SQLAlchemy==1.1.5
Werkzeug==0.11.15
gunicorn==19.0.0
gevent==1.2.1
The issue here is that you're not running any web dynos. You can tell Heroku to do this via:
$ heroku ps:scale web=1
This will force Heroku to spin up a web dyno, thereby executing your gunicorn command.
After 3 hours of debugging, I've figured out why my app was causing this error:
My Procfile was incorrectly cased
gunicorn wasn't installed in my venv
IMO, this error should be raised on Heroku's end. As a beginner, this sort of error is difficult to trace.
Update:
To clarify, Procfile is correctly cased and procfile is not correctly cased. It should start with a capital "P".
More info on dyno configuration – more on initializing your heroku app.
I ran into the same problem but from a different cause. I had the hobby tier, but then canceled it and reverted back to the free tier. Doing this caused the error and how I fixed it was just re running the command from the cli:
heroku ps:scale web=1
Before this command:
heroku ps:scale web=1
I had to remove and add buildpacks again and empty commit it and redeploy it to heroku.
heroku buildpacks:clear
heroku buildpacks:add --index heroku/python
I was having an issue here too. My problem was that my Procfile was "Procfile.txt" .
What solved my issue was to remove the file extension from Procfile, then recommit
and push stuff to heroku
Login to your Heroku dashboard and open your projects.
Go to Settings.
Delete heroku/python from the list of buildpacks
Then click Add buildpack → Choose "Python" → Save Changes.
Activate your environment in your code.
Run heroku ps:scale web=1.
And you're done!
This isn't the problem with your code, but I've gotten this error message a couple of times now and the mistake that I've made that has caused it has been writing
web:gunicorn
instead of
web: gunicorn
That space can really cause a lot of issues.
My issue is that Heroku removed the free plans. To solve such an issue go to Heroku and select/change your free plan to for example "eco" plan.
I have a UAT version I only enable during client development.
I have a custom dyno script but it's turned to the free version. So the app was not starting as my script was not running. When I enabled the Dyno the toggle was still off :rolleyes:
I don't have the reputation to reply to the correct comment, but for me the issue was that I didn't have the run.gunicorn.sh file in my root directory, this resulted in the same "No web processes running" error.
If you don't have this file, create it with contents:
gunicorn -b :5000 --access-logfile - --error-logfile - build:app
Where 'build' is the name of your python file (build.py in this case) and app is the name of your app in the code.
Also make sure that gunicorn is included in requirements.txt, like others have already pointed out.
Yeah I was also using web heroku-php-apache2 dyno and reverted it back to free tier and that caused the dyno to sleep fortunately executing heroku ps:scale web=1 -a <app name> did the magic.
Change your Procfile file from
web:gunicorn to web gunicorn (remove the ':')
I fixed the issue by going to Configure Dynos and enabling the only dyno I had manually.
uff..that took some time,so the fixes i had to make were:
'Procfile' with upper case P.
web: gunicorn wsgi:app (with a space after web: in procfile)
Making sure the requirements.txt are in the root project folder.
I was missing dynos on the web gui. The cli command to scale did not work. I also may have had an incorrect run:web declaration with missing $PORT. To fix:
heroku.yml must have a web declaration using the $PORT var:
build:
docker:
web: Dockerfile
run:
web: uvicorn main:app --reload --host 0.0.0.0 --port $PORT
I then pushed to heroku.
After that it must have added the web dyno, I could then run:
heroku ps:scale web=1
And now the fastapi uvicorn runs.
Pay attention to the Procfile naming and location (https://devcenter.heroku.com/articles/procfile) The Procfile is always a "simple text file" that is named Procfile without a file extension.(Procfile.txt not acceptable!) The Procfile must live in your app's root directory. It does not function if placed anywhere else.
Faced the exact same problem turns out I had the Profile in .gitignore
I was placing my django Procfile in the directory with settings.py and not the root directory and that gave me the H14 error. I fixed the error with this and I didn't need to do anything else they say.
Procfile
web: gunicorn <django-root-name(containing wsgi)>.wsgi
There are many things that can go wrong here. Its a combination of poor shepherding by heroku and ambiguous use between flask & gunicorn.
Here is a good guide that will get you up and running:
To anyone who may come across this...
delete your Procfile
create 'Procfile' with upper case P.
in your Procfile type: web: gunicorn <nameOfRootFile>:app (with a space after web: in procfile) mine for example was web: gunicorn app:app another way I wrote it that worked was this: web: gunicorn -w 4 "app:create_app()" -t 120
Making sure the requirements.txt are in the root project folder. (you can run pip freeze > requirements.txt if you do not have the file created
deploy to heroku
heroku ps:scale web=1 (you can specify app name to like this heroku ps:scale web=1 -a appname
finally in terminal run heroku restart
heroku open
these are all the steps i took to get mine to work
web: gunicorn weather.wsgi --log-file -
this worked for me, just make sure your Procfile is in the right format, and specify the app you are connecting to, in my case it's the weather app. Enjoy
What worked for me was adding on the second line of the procfile:
heroku ps:scale web=1
The first line must contain:
web: gunicorn "filename":"main method name"
error H14 happen while deploying to heroku
this is my procfile:
web: gunicorn -w 4 -b 0.0.0.0:$PORT -k gevent main:app
log on heroku:
2017-01-23T10:42:58.904480+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=meetcapstone.herokuapp.com request_id=df88efb5-a81a-4ac0-86dc-4e03d71266bb fwd="81.218.117.137" dyno= connect= service= status=503 bytes=
2017-01-23T10:42:59.009135+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=meetcapstone.herokuapp.com request_id=21cea981-36b0-4410-891f-548bbc29f0ee fwd="81.218.117.137" dyno= connect= service= status=503 bytes=
requirements:
Flask==0.11.1
passlib==1.7.0
SQLAlchemy==1.1.5
Werkzeug==0.11.15
gunicorn==19.0.0
gevent==1.2.1
The issue here is that you're not running any web dynos. You can tell Heroku to do this via:
$ heroku ps:scale web=1
This will force Heroku to spin up a web dyno, thereby executing your gunicorn command.
After 3 hours of debugging, I've figured out why my app was causing this error:
My Procfile was incorrectly cased
gunicorn wasn't installed in my venv
IMO, this error should be raised on Heroku's end. As a beginner, this sort of error is difficult to trace.
Update:
To clarify, Procfile is correctly cased and procfile is not correctly cased. It should start with a capital "P".
More info on dyno configuration – more on initializing your heroku app.
I ran into the same problem but from a different cause. I had the hobby tier, but then canceled it and reverted back to the free tier. Doing this caused the error and how I fixed it was just re running the command from the cli:
heroku ps:scale web=1
Before this command:
heroku ps:scale web=1
I had to remove and add buildpacks again and empty commit it and redeploy it to heroku.
heroku buildpacks:clear
heroku buildpacks:add --index heroku/python
I was having an issue here too. My problem was that my Procfile was "Procfile.txt" .
What solved my issue was to remove the file extension from Procfile, then recommit
and push stuff to heroku
Login to your Heroku dashboard and open your projects.
Go to Settings.
Delete heroku/python from the list of buildpacks
Then click Add buildpack → Choose "Python" → Save Changes.
Activate your environment in your code.
Run heroku ps:scale web=1.
And you're done!
This isn't the problem with your code, but I've gotten this error message a couple of times now and the mistake that I've made that has caused it has been writing
web:gunicorn
instead of
web: gunicorn
That space can really cause a lot of issues.
My issue is that Heroku removed the free plans. To solve such an issue go to Heroku and select/change your free plan to for example "eco" plan.
I have a UAT version I only enable during client development.
I have a custom dyno script but it's turned to the free version. So the app was not starting as my script was not running. When I enabled the Dyno the toggle was still off :rolleyes:
I don't have the reputation to reply to the correct comment, but for me the issue was that I didn't have the run.gunicorn.sh file in my root directory, this resulted in the same "No web processes running" error.
If you don't have this file, create it with contents:
gunicorn -b :5000 --access-logfile - --error-logfile - build:app
Where 'build' is the name of your python file (build.py in this case) and app is the name of your app in the code.
Also make sure that gunicorn is included in requirements.txt, like others have already pointed out.
Yeah I was also using web heroku-php-apache2 dyno and reverted it back to free tier and that caused the dyno to sleep fortunately executing heroku ps:scale web=1 -a <app name> did the magic.
Change your Procfile file from
web:gunicorn to web gunicorn (remove the ':')
I fixed the issue by going to Configure Dynos and enabling the only dyno I had manually.
uff..that took some time,so the fixes i had to make were:
'Procfile' with upper case P.
web: gunicorn wsgi:app (with a space after web: in procfile)
Making sure the requirements.txt are in the root project folder.
I was missing dynos on the web gui. The cli command to scale did not work. I also may have had an incorrect run:web declaration with missing $PORT. To fix:
heroku.yml must have a web declaration using the $PORT var:
build:
docker:
web: Dockerfile
run:
web: uvicorn main:app --reload --host 0.0.0.0 --port $PORT
I then pushed to heroku.
After that it must have added the web dyno, I could then run:
heroku ps:scale web=1
And now the fastapi uvicorn runs.
Pay attention to the Procfile naming and location (https://devcenter.heroku.com/articles/procfile) The Procfile is always a "simple text file" that is named Procfile without a file extension.(Procfile.txt not acceptable!) The Procfile must live in your app's root directory. It does not function if placed anywhere else.
Faced the exact same problem turns out I had the Profile in .gitignore
I was placing my django Procfile in the directory with settings.py and not the root directory and that gave me the H14 error. I fixed the error with this and I didn't need to do anything else they say.
Procfile
web: gunicorn <django-root-name(containing wsgi)>.wsgi
There are many things that can go wrong here. Its a combination of poor shepherding by heroku and ambiguous use between flask & gunicorn.
Here is a good guide that will get you up and running:
To anyone who may come across this...
delete your Procfile
create 'Procfile' with upper case P.
in your Procfile type: web: gunicorn <nameOfRootFile>:app (with a space after web: in procfile) mine for example was web: gunicorn app:app another way I wrote it that worked was this: web: gunicorn -w 4 "app:create_app()" -t 120
Making sure the requirements.txt are in the root project folder. (you can run pip freeze > requirements.txt if you do not have the file created
deploy to heroku
heroku ps:scale web=1 (you can specify app name to like this heroku ps:scale web=1 -a appname
finally in terminal run heroku restart
heroku open
these are all the steps i took to get mine to work
web: gunicorn weather.wsgi --log-file -
this worked for me, just make sure your Procfile is in the right format, and specify the app you are connecting to, in my case it's the weather app. Enjoy
What worked for me was adding on the second line of the procfile:
heroku ps:scale web=1
The first line must contain:
web: gunicorn "filename":"main method name"
I have tried everything and cannot figure out why it wont create dynos. I have a java web app using maven, deploys to heroku successfully but does not have dynos.
Procfile declares types -> (none) but why?
My error:
at=error code=H14 desc="No web processes running" method=GET path= method=GET path="/list" host=employee-db10.herokuapp.com request_id=some_request_id fwd="XX.XXX.XX.XXXX" dyno= connect= service= status=503 bytes= protocol=https
My procfile is as follows:
web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war
I have also tried this for my procfile and it did not work:
web: java -jar target/dependency/webapp-runner.jar target/*.war --port $PORT
I also see this in my build log and it could also be a problem. I tried building this using a war earlier and switched over to webapp-runner after reading online.
remote: [WARNING] Some problems were encountered while building the effective model for jsp-servlet-jdbc-mysql-example:jsp-servlet-jdbc-mysql-example:war:0.0.1-SNAPSHOT
You can use the heroku ps:scale command to add (or remove) dynos at will:
heroku ps:scale web=1
This command will instruct Heroku to run a single web process (as specified in your Procfile). If you'd like to have 2 dynos, you could say:
heroku ps:scale web=2
Etc. Here's an article from Heroku's docs that explain it in more detail.
After many research and tried, I still cannot resolved the problem. I use Vapor Toolbox: 3.1.2 & Vapor Framework: 2.3.0 and Swift 4.0.3(Xcode 9.2 on macos-high-sierra) to build a simple website(without database). But after run vapor heroku push successful, I try goto heroku dashboard to open my website, but it didn't work. I try to run heroku logs and got the result with crashed:
2017-12-26T09:04:10.000000+00:00 app[api]: Build succeeded
2017-12-26T09:10:00.192686+00:00 heroku[web.1]: Process exited with status 127
2017-12-26T09:10:00.207462+00:00 heroku[web.1]: State changed from starting to crashed
2017-12-26T09:10:00.210981+00:00 heroku[web.1]: State changed from crashed to starting
2017-12-26T09:10:03.369454+00:00 heroku[web.1]: Starting process with command `leeswift --env=production --port=19489`
2017-12-26T09:10:00.072884+00:00 app[web.1]: bash: leeswift: command not found
2017-12-26T09:10:05.460027+00:00 app[web.1]: bash: leeswift: command not found
2017-12-26T09:10:05.560609+00:00 heroku[web.1]: Process exited with status 127
2017-12-26T09:10:05.594754+00:00 heroku[web.1]: State changed from starting to crashed
2017-12-26T09:11:28.858638+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=leeswift.herokuapp.com request_id=0eab887e-dba0-488e-b3f6-899de07898d6 fwd="118.69.108.38" dyno= connect= service= status=503 bytes= protocol=https
Please help me to fix it.
bash: leeswift: command not found
Your heroku buildpack cannot find the produced executable for the vapor app. This is likely an issue with the name/path to the application. I haven't used heroku yet, but Swift produces it's executbles in .build/release/<my-app> or .build/debug/<my-app> depending on your compilation mode.
I think you have an error in the 'Procfile' file. for example, this is mine:
web: Run --env=production --workdir=./ --config:servers.default.port=$PORT
Please follow the below steps to solve your issue.
How to create swift backend API with the help of Vapor framework. Another framework is also available in the market. But we are choosing swift vapor.
Let’s start.
Install vapor in your system.
Step 1. Run below command to install vapor
brew install vapor/tap/vapor-beta
Check whether vapor installs or not run below command.
vapor-beta --help
These will be useful command of vapor.
Command only when you are in project directory.
You can
# Created vapor project
vapor new myProjectName
# Build vapor project
vapor build
# Run vapor project
vapor run
# You can configure Xcode. You should be inside created project directory.
vapor Xcode
When you have made changes in project file or add new feature for update you have below command.
vapor Xcode
You can run thru local server test API. Out will be “Hello World”
curl http://localhost:8080/hello
===========================================PostgreSQL Setup================================================
Setting Up for local PrortgeSQL. Run below command.
brew install postgresql
Start local database server. Run below command
pg_ctl -D /usr/local/var/postgres start
Stop the local database server. Run below command.
pg_ctl -D /usr/local/var/postgres stop
When yow wish to run PostgreSQL as background service with launch you can use brew server. Run below command.
brew services start postgresql
Let start Postgres the by this.
psql -d postgres
Create data base by running below command:
create databas databaseName
create databas ashi-app # Actual command
create user by running below command:- Grant that user the privileges it need with by running below command.
create user username
create user ashi-app-user # Actual command
grant all privileges on database databaseName to userName
# Actual command
grant all privileges on database ashi-app to ashi-app-user
===========================================PostgreSQL Setup================================================
===========================================Deploy fresh app on Heroku================================================
Deploy new swift vapor app on Heroku without database.
Consider you already created Vapor project without database.
Step 1. Navigate on cd MyApp.
cd myApp
# Actual command
cd ashi-api
Step 2. Create swift version file inside your root project directory.Run below on terminal.
echo 5.1.3 > .swift-version
Step 3. Create Procfile file inside your root project directory.Run below on terminal.
echo web: Run serve --env production --hostname 0.0.0.0 --port $PORT > Procfile
Step 4. Add file git and commit by below command
git add .
git commit -m ‘App Setup’
Step 5. You should generate linux tests file by below command.
swift test --generate-linuxmain
Step 6. Add again modified in git by below command.
git add .
git commit -m ‘Tests setup’
Step 7. Login on Heroku. Required to create app on heroku for deployment. So we have login on heruko. By running below command we can login.
heroku login
Step 8. Once login done create heroku app. Name must we unique most prefer is app-appname.
heroku apps: create myAppName
heroku apps: create ashi-api # Actual command
Step 9. Add swift build pack with app. For compiling on hereto we have to add buildback. Heroku doesn’t support inbuild pack for swift.
heroku buildpacks:set https://github.com/vapor-community/heroku-buildpack -a myproject
# Actual command
heroku buildpacks:set https://github.com/vapor-community/heroku-buildpack -a ashi-api
Step 10. Find command push changes on sever.
git push heroku master
Now you app and API will available for testing…
===========================================Deploy fresh app on Heroku================================================
======================Set data base with deployed app and next version of deployment==================================
Step 1. Do database configuration. Replace sqlite database with postgreSQL. Because Heroku is not supporting sqlite.
Replace in App->configure.swift. and import in Todo.h TodoController.h
import FluentPostgreSQL
// Configure a PostgreSQL database
let postgreSQLConfig: PostgreSQLDatabaseConfig
if let url = Environment.get("DATABASE_URL") {
postgreSQLConfig = PostgreSQLDatabaseConfig(url: url)!
} else {
postgreSQLConfig = PostgreSQLDatabaseConfig(hostname: "localhost", username: "app_test")
}
let postgreSQL = PostgreSQLDatabase(config: postgreSQLConfig)
// Register the configured PostreSQL database to the database config.
var databases = DatabasesConfig()
databases.add(database: postgreSQL, as: .psql)
services.register(databases)
Step 2. Install the heroku command with home-brew by running.
brew tap heroic/brew && brew install heroku
Step 3. We can add postgreSQL in app by running command.
heroic addons:create heroic-postgresql:hobby-dev
Step 4. Add update file in git by running below command.
git add .
git commit -m ‘Added PostgreSQL file’
Step 5. Find command push changes on sever.
git push heroku master
The second version will be available for testing with postgreSQL.
======================Set data base with deployed app and next version of deployment==================================
I try to create simple java App on Heroku.
I following step by step from http://samuelsharaf.wordpress.com/2011/11/06/create-a-simple-java-web-app-using-maven-and-upload-to-heroku/ to do it.
But when i try to deploy my app on heroku project i got error message like bellow when i try to view log
$ heroku logs -t
2012-07-10T02:15:14+00:00 heroku[slugc]: Slug compilation started
2012-07-10T02:15:27+00:00 heroku[api]: Add shared-database:5mb add-on by anwar#meruvian.org
2012-07-10T02:15:27+00:00 heroku[api]: Release v2 created by anwar#meruvian.org
2012-07-10T02:15:27+00:00 heroku[api]: Add MAVEN_OPTS, PATH, JAVA_OPTS config by anwar#meruvian.org
2012-07-10T02:15:27+00:00 heroku[api]: Release v3 created by anwar#meruvian.org
2012-07-10T02:15:28+00:00 heroku[api]: Release v4 created by anwar#meruvian.org
2012-07-10T02:15:28+00:00 heroku[api]: Deploy cb1cfa2 by anwar#meruvian.org
2012-07-10T02:15:28+00:00 heroku[web.1]: State changed from starting to down
2012-07-10T02:15:28+00:00 heroku[slugc]: Slug compilation finished
2012-07-10T02:16:51+00:00 heroku[router]: Error H14 (No web processes running) -> GET fierce-ocean-9944.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
This is my url on heroku :
http://fierce-ocean-9944.herokuapp.com/
What that error ?
How to solve this ?
Thanks
Have you tried scaling one of your process types? e.g. heroku ps:scale web=1
Or rather, check what's your current web count by using 'heroku ps'
See https://devcenter.heroku.com/articles/scaling
I kept running into the same problem. The sample python application ran fine, but mine did not. I logged into the dashboard and noticed that the web dyno count for my app showed zero. So I bumped it up on the web gui (i.e., strech the slider widget until you get a non-zero count.) and that worked. My dashboard also showed the heroku ps:scale web=1 dyno at zero, and I left it as zero.
You need to remove your ProcFile and add again
git rm ProcFile –f
Again add the ProcFile to project
Check the spellings
Content structure of the ProcFile
ProcFile should not contain any extensions.
After that do the normal git procedure,
git add .
git commit –m “add procfile”
git push heroku master
You will see,
Procfile declares types -> web
Instead of
Procfile declares types -> (none)
If you are using a container to build a web application, create a heroku.yaml file like this in your project's root:
build:
docker:
web: Dockerfile
run:
web: [PUT YOUR CMD COMMAND IN DOCKERFILE HERE]
Then add heroku.yaml to git repository. You can remove Procfile (optional). Finally deploy your repository as the following:
git add .
git commit -m "Add heroku.yml"
heroku stack:set container -a [YOUR APP NAME]
git push heroku master
If your are pushing to heroku for the first time, you should run heroku git:remote -a [YOUR APP NAME] before git push heroku master