DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • What Developers Need to Know About the Price Checker App
  • Application Modernization and 6 R's
  • How Can Artificial Intelligence Transform Software Testing?
  • 3 GPT-3 Tools for Developers, Software and DevOps Engineers, and SREs

Trending

  • The Evolution of Scalable and Resilient Container Infrastructure
  • How To Introduce a New API Quickly Using Quarkus and ChatGPT
  • Supervised Fine-Tuning (SFT) on VLMs: From Pre-trained Checkpoints To Tuned Models
  • Traditional Testing and RAGAS: A Hybrid Strategy for Evaluating AI Chatbots
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. A Comprehensive Guide To Deploy Ruby Bot Live On Heroku

A Comprehensive Guide To Deploy Ruby Bot Live On Heroku

Software deployment is an important part of implementing your software application after its initial phase of development.

By 
Jack David user avatar
Jack David
·
Mar. 19, 21 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
2.4K Views

Join the DZone community and get the full member experience.

Join For Free

Software deployment is an important part of implementing your software application after its initial phase of development. On the other hand, a bot is a continuous running script that performs a given task or responds to any triggered action on the occurrence of a specified event. Developers use them to carry out redundant activities. Let us find out more about these computing aspects.

What Exactly is Software Deployment?

Software Deployment encompasses all the processes, steps, and activities that make software ready to deliver from developers to users. It is the process of rolling out customized software that conforms to its client's demands in an interconnected world. Software deployment enables updates, applications, modules, and patches that optimizes the performance of the software. One of the key advantages of deployment is that testing ensures a bug-free, error-free process, and after the maintenance, the software is produced with additional updates and functions. 

How to Deploy Software

 The software deployment process includes three essential steps, as highlighted below:

 Preparation 

To prepare the software for deployment, developers compile the codes necessary for the functionality of the application and other libraries, configuration files, or resources. A single software is created by huddling all these items together. It is also necessary to validate whether the host app is correctly configured and its smooth functioning during preparation. 

Testing

The probability of bug appearance in the production server is high after the deployment process. In this stage, through pre-configured automated tests of a text server, the developers identify bugs and errors that will be fixed before deploying the update. 

Deployment

After confirming integral maintenance, the software is deployed to the live domain. If necessary, the developers will also include a database update before going live. Subsequently, it secures the software from all live server errors to maximize its performance. 

A complete manual to deploying Ruby Bot' Live on Heroku in a step-wise manner is presented below.

Step 1:

Develop a file titled Procfile on the root directory of the project and put in the following codes in the Procfile like:

Java
 




xxxxxxxxxx
1


 
1
web: ruby my_app.rb -p $PORT
2
worker: bundle exec ruby bin/main.rb



Code in ProcfileNow, build another file named my_app.rb within the project root directory and add the code from the following step.

Step 2:

Use the following code in the next step:

Java
 




xxxxxxxxxx
1


 
1
require 'sinatra'  
2
get '/' do  
3
  redirect 'http://bot_url_from_BotFather', 303  
4
end



Code in my_app.rbNB: http://bot_from_BotFather is your Telegram bot URL from Botfather.

In case you've forgotten, you can obtain your Telegram bot URL.

Step 3:

In this step you need to go to Gemfile and add the snippets below: 

In the Gemfile, you need to include the gem sinatra,

Java
 




xxxxxxxxxx
1


 
1
Gem 'sinatra'



Adding Gem Sinatra

Step 4: 

Now run bundle install.

This command installs all dependencies that are required for deployment. 

Some Important Snippets and Their Explanation:

Java
 




xxxxxxxxxx
1


 
1
web: ruby my_app.rb. -p $PORT



This code guarantees the transformation of the app to the web. If the transformation of the app is successful, then it suggests that the app has been deployed to Heroku.

Java
 




xxxxxxxxxx
1


 
1
worker: bundle exec ruby bin/main.rb



This code tracks the shift of the bot to the worker. If this is enabled then the bot will start automatically. Do not hesitate to replace ruby bin/main.rb with your respective command that can enable your bot to start locally. 

Java
 




xxxxxxxxxx
1


 
1
http://bot_url_from_BotFather ,303



This URL will redirect the bot to Telegram.

Step 5: 

For creating an app on Heroku:

Run Heroku create <name_of_your_bot> from the terminal. Remember that <name_of_your_bot> is not compulsory, but only optional. Assign your name if you want to customize your URL on Heroku, or else Heroku will produce an automated URL. The name can be anything but hyphenate it like comic-telegram-bot. 

Step 6: 

Now run git and push Heroku master to move your bot to Heroku.

If you are not a master branch, then run git push Heroku master:<current_branch>. In this <current_branch> is the title of your present branch.

Step 7: 

After pushing your bot to Heroku, run Heroku ps to open the app's dyno settings that will allow you to ensure whether the app is transmitted to the web, which means the deployment to Heroku is successful, and if the bot sent it to the worker, then the bot will start automatically. If all these steps are completed without any errors, then both the web and worker will be equal to 1. If the web or the bot isn't 1, then for a quick fix, run heroku ps: scale web=1 worker=1. 

Step 8:

If there is any ENV variable, to add it visit the settings on the Heroku dashboard. To illustrate, if you want to login into Heroku and suppose you have Token=' my_telegram_API_key' in the ENV file, then click on Reveal Config Vars and add Token as KEY and my_telegram_API_key as the VALUE. And finally, click Add. 

Step 9:

To redirect yourself to Telegram, click on Open app after successfully adding the ENV variable. Moreover, click Open only when it's prompted on the screen. Note that if your API is not encrypted, then do not add the ENV variable. Hardcoded API key will not enable you to add ENV variable in Heroku. If your bot goes to sleep after one or two hours, then do not panic. To solve this, login to Heroku and click on Open app. This will assist you to interact with your bot live without starting it locally.

Conclusion

Using these steps, you will be effortlessly able to deploy your Ruby bot live on Heroku in no time. It is best to use the service of expert programmers and coders for software deployment purposes.

Software app Software deployment

Published at DZone with permission of Jack David. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • What Developers Need to Know About the Price Checker App
  • Application Modernization and 6 R's
  • How Can Artificial Intelligence Transform Software Testing?
  • 3 GPT-3 Tools for Developers, Software and DevOps Engineers, and SREs

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!