As you all know that Heroku is a platform as a service which helps developers to build, run, and operate applications entirely in the cloud. I have started with free dyno which is for experimenting and only has 512 MB RAM.
I am using Windows so the steps will be of Windows machine.
At first I need to download the Heroku CLI from https://devcenter.heroku.com/articles/heroku-cli. It says that it updates the path but you need to double check, for my case I need to manually update the Path. Before installing just check that you have node and npm installed in your system.
Then I logged into Heroku using command heroku login which asked my Email and Password. Once authenticated, I created my first app using command heroku create which creates a app for me.
Since my app was not in GitHub, I need to create it using git init and then adding heroku as my remote using command git remote add heroku https://git.heroku.com/my-app-name.git. Then we need to commit the code using command git commit -am "Initial Commit". Once done, just pushing it to heroku git push heroku master.
Since my app is a bot, I need to create a ProcFile on the root of the directry, the contents of the ProcFile is shown below
worker: node index.js
I pushed the code again with the same command git push heroku master. And then switched on the Worker and switched off the web as shown below.
Also since I was using some confidential information in my bot, like a bot key I created a config vars in the settings tab as shown below and then used it using process.env.KEY and process.env.NAME in the bot.
In this way you can deploy your bot with Heroku. Happy Coding :)
Please like and share the CodingDefined.com blog if you find it useful and helpful.
I am using Windows so the steps will be of Windows machine.
At first I need to download the Heroku CLI from https://devcenter.heroku.com/articles/heroku-cli. It says that it updates the path but you need to double check, for my case I need to manually update the Path. Before installing just check that you have node and npm installed in your system.
Then I logged into Heroku using command heroku login which asked my Email and Password. Once authenticated, I created my first app using command heroku create which creates a app for me.
Since my app was not in GitHub, I need to create it using git init and then adding heroku as my remote using command git remote add heroku https://git.heroku.com/my-app-name.git. Then we need to commit the code using command git commit -am "Initial Commit". Once done, just pushing it to heroku git push heroku master.
Since my app is a bot, I need to create a ProcFile on the root of the directry, the contents of the ProcFile is shown below
worker: node index.js
I pushed the code again with the same command git push heroku master. And then switched on the Worker and switched off the web as shown below.
Also since I was using some confidential information in my bot, like a bot key I created a config vars in the settings tab as shown below and then used it using process.env.KEY and process.env.NAME in the bot.
In this way you can deploy your bot with Heroku. Happy Coding :)
Please like and share the CodingDefined.com blog if you find it useful and helpful.
Related articles
- How to create Simple Twitter Bot in Node.js
- Legacy Browser Support for using Babel
- Getting Started with Node.js Koa 2 Framework
- Web Scraping Libraries for Node.js Developers
- How to Create Simple RSS Reader in Ionic Application
- Simple RESTful API in Nodejs
- How to Get Latest Tweets of a particular HashTag using Nodejs
- How to Intercept HTTP requests in Node.js
- Node for Android
- Capture Screen of Web Pages through URL in Nodejs
Hey, I have been worked in expressjs with pm2. this one is really good content for who learning nodejs. Thanks dude.
ReplyDelete