Skip to content

Setting up development environment

Tay Kang Sheng edited this page Jul 22, 2023 · 2 revisions

This application is made up of 4 parts. In most cases you probably don't need to start all the parts, so follow the instructions where necessary.

  1. Rails app
  2. Scheduler
  3. Job worker
  4. Telegram bot integration

1/ Rails app

This is the core of the entire web application. This app serves the website and also the API. A Postgres database is also required to start the Rails app so get it running before you get started. If you are using Mac, you can use PostgresApp to get started easily.

How to start:

  1. Open a new terminal
  2. run bin/rails s

2/ Scheduler

The scheduler is currently shipped together with Web application. Therefore only 1 instance of the web application should be run (or deployed) to prevent multiple scheduler instance running.

How to start:

  1. No command needed to start scheduler as it is started with the Rails app

3/ Jobs worker

All jobs are enqueued with the DelayedJob ActiveJob queue adapter. In order for your enqueued jobs to be processed, you will need to start a job worker.

How to start:

  1. Open a new terminal
  2. run bin/rails jobs:work

4/ Telegram bot integration

The application integrates with the Telegram API to power the RubySGBot. We have a test RubySGTestBot that is used for development environment. You can follow the steps below to set up the integration for your development environment.

How to start:

  1. Download the API collection (ruby-sg-reboot-insomnia-2023-07-22.yaml.zip) and import the API collection into Insomnia or Postman
  2. Get the access token for RubySGTestBot from @taykangsheng and update access-token in environment variables
  3. Start a tunnelling session to your Rails application by using a service like Ngrok and update app_url in environment variables with the url of the tunnelling session.
  4. Configure RubySGTestBot's update webhook to point to the tunnelling session by running the Set webhook URL API request
  5. Add RubySGTestBot to any telegram group and you should should see telegram pushing webhook events to your tunnelled session