-
Notifications
You must be signed in to change notification settings - Fork 118
Deployment
Max Melentiev edited this page Nov 22, 2022
·
3 revisions
Here are described two basic ways to deploy your bot.
Pros:
- Scalable.
- No need to manage separate process for bot.
Cons:
- Requires HTTPS on server. P.S. Telegram supports self-signed certificates.
- Setup domain in
config/environments/production.rb
:routes.default_url_options = {host: 'yourdomain.com', protocol: 'https'} # https is necessary!
- Deploy as usual Rails app.
- Run
rake telegram:bot:set_webhook RAILS_ENV=production
to update webhook url for all configured bots. Self-signed certificate can be provided withCERT=path/to/cert.pem
. - Re-run this rake task each time domain, bot token or self-signed sertificate changes.
- Deploy app as usual.
- Run
bot.set_webhook(url: your_url [, cert: File.open('self/signed/cert')])
for each bot. - Re-run previous step each time webhook url or self-signed sertificate changes.
Pros:
- No need to setup HTTPS.
Cons:
- Not scalable: only one process can poll for updates at the moment.
- Requires separate process for bot (harder to deploy).
- Create ruby file that runs poller (in some cases rake task will be enough).
- Use any process manager (upstart, init.d, god, daemons gem) to start/stop/restart poller.
- Deploy as usual.
See example
using daemons
gem.
Same as rails app, just set controller class for each poller explicitly.