SLACK MEETUP BOT - DEPLOYMENT

In school, when we worked on the project as a team, we just hosted the app on Heroku. With Heroku, the app eventually went into hibernation. On my personal portfolio, I wanted people to have the ability to test out the app. Also to add to that trouble MongoDB was not supported by Heroku anymore at the time of writing. So I needed to keep the app active on Heroku, move the database from Heroku, and keep the database active because the database was also going to sleep.

April 4, 2022

So what per se is the problem?

When the app was built in school yet, the goal was just to get a working app. Longer-term hosting wasn't a priority because we only needed it for class. On my portfolio site I am trying to have all the apps and projects I worked on to have a working prototype. I want people to have the chance to play around with my apps and see them in action. Something tangible is worth more than just words.

The way Heroku works is after a period of inactivity the app will go to sleep to conserve resources. It will wake up after it gets something trying to access it. The Slack channel that has the bot running in is always active. If I try to use the bot in the channel when the Heroku app server is down I will just not get any reply. That isn't necessarily a problem because after a few moments after running the first command I can run it again and it will work. The app will wake up in those few moments. I personally didn't want to settle with that experience. I was hoping to have the app work every time.

That wasn't the only issue though. The app was built over a year ago. Heroku has stopped supporting MongoDB since then. I had to have the database hosted externally from Heroku. Once I figured out how to do that I ran into another issue. After some time of inactivity on the database server, the database would also go to sleep. So now if I wake up the app on Heroku it still won't work. It needs the database but the database is asleep and doesn't just wake up. It needs to get activated manually by logging into the dashboard for the MongoDB database.

Stirring up the gray matter

I had a few ideas of how to fix the various issues. The main problem I needed to address was how to keep the Heroku server up for the app. I had a chron job running on the bot server that would repopulate the database with more current data every 12 hours. That was enough to keep the database in active status. Therefore the only work that needed to get done with the database was to move it out of Heroku. That was just a quick google search and tutorial.

Javascript script

My first idea was to have a short javascript script running on my personal portfolio. Have it ping my bot server every 30 minutes. I wasn't too happy with that solution because my personal portfolio repository would have code in it that isn't in any way related to it. It should work though. While researching this method I got the idea of running a chron job on my personal DigitalOcean server. I figured it was possible but it wasn't my first idea because I thought it would be just super easy to run a javascript script. After more research it seemed like running a chron job on my server is just as easy if not easier yet.

Chron job on my server

I guess it would have been possible to just create a separate Heroku app that would only do one thing of pinging my bot server. I would then need something to keep that app awake. I think that would have worked but I wasn't a hundred percent sure. I suspected Heroku might require external requests to the server outside of Heroku to keep it awake. Either way, I didn't think that was too clean. My personal server was completely set up by me and I controlled what ran and how. That seemed like a much more solid solution.

Turns out an ubuntu server comes with chron job functionality built-in out of the box without needing to install anything. Researching how to run the chron job it made sense in my mind to create a chron job that would run a file every 30 minutes that would have a script to ping my bot server. I was thinking of writing a python script that would do what I needed. After more research, I realized this is probably all possible within a single chron job script.

I'm not sure I understood everything correctly but it seemed like just pinging my bot server from the DigitalOcean server wasn't super straightforward. From what I understood the ping command would need root permissions. For some reason, it wouldn't want to work. It would not wake up the bot server.

I later realized I could basically ping the server with a curl command. That did wake up the bot server. One thing that worried me was I'd be downloading data from the bot server with the curl command every 30 minutes. I wasn't sure how the DigitalOcean server deals with that data. I didn't want it to keep writing it to temporary storage anywhere on the server and hogging up all the storage on my server. So what I came up with in the end was a curl command that would cut out just the headers from the response and more specifically just the status header. Then I would just write that to a built-in log on the server that just deletes everything that gets written to it. Turns out all that functionality is available on the server by default.

Basic solution summarized

So basically all I really had to do was set up a chron job and run a curl command requesting data from the bot server. I would then delete the data in the response. This would keep the Heroku app active and while the app is active, it keeps the database active by writing new data to it every 12 hours.

Not perfect but it works

In the end, this is still not a perfect solution. The link to join the Slack channel will automatically add users only from a couple of email domains. Specifically, only accounts with google.com, inbox.com, and mail.com emails could be added automatically. Everyone else would have to send me a request and I would have to manually approve them. There was no way around this. This was a limiting factor from Slack's end. I'm not sure why they are so limited.

So the Slack channel is always active now. As is the bot server and database. If you want to check it out, use the live app link at the top of the page or just go here. If you need to get approved, send me a request through that link and I'll approve anyone as soon as possible.

Further Reading

About the Slack Meetup Bot

APR

04

2022

Comments

OCT

02

2023

Today

Вася
Jun 6, 2022 • 4:54 p.m. EDT

Hey there slacker!

JUN

06

2022

Alonzoevarp
Apr 21, 2023 • 10:39 p.m. EDT

uae virtual mobile number

APR

21

2023

HaroldPat
Apr 26, 2023 • 4:36 p.m. EDT

сдается

APR

26

2023

Cesarduame
Apr 28, 2023 • 10:26 p.m. EDT

Mental

APR

28

2023

DavidCop
May 1, 2023 • 2:08 p.m. EDT

Car Rental in Barcelona | SIXT rent a car

MAY

01

2023

QuentinDrync
May 5, 2023 • 1:56 a.m. EDT

Аренда авто в Стамбуле стоимость 2023

MAY

05

2023

avenue17
May 5, 2023 • 7:31 p.m. EDT

I am assured, that you have misled.

MAY

05

2023

Shanepelry
May 11, 2023 • 10:24 a.m. EDT

kukhareva.com

MAY

11

2023

windaddyindia
May 22, 2023 • 10:34 p.m. EDT

In my opinion you are not right. I am assured. I can prove it. Write to me in PM, we will discuss.

MAY

22

2023

Brentboida
May 31, 2023 • 11:42 p.m. EDT

https://pq.hosting/vps-vds-netherlands-meppel

MAY

31

2023

20betPrupe
Jun 14, 2023 • 10:55 p.m. EDT

Betting tips

JUN

14

2023

Frankdiary
Jun 20, 2023 • 3:42 p.m. EDT

1xbet registration online

JUN

20

2023

LloydlaF
Jun 26, 2023 • 4:20 p.m. EDT

https://rent-a-car-alanya.com/pl/

JUN

26

2023

Некулицы Иван
Aug 18, 2023 • 10:29 p.m. EDT

I am ready to help you, set questions. Together we can come to a right answer. _ _ _ _ _ _ _ _ _ _ _ _ _ _ Некулицы Иван dayz hosting

AUG

18

2023

Jefferyexesk
Sep 6, 2023 • 12:23 p.m. EDT

Yes, really. I agree with told all above. Let's discuss this question. Here or in PM. ------------ https://servers.expert/hoster/tverhost

SEP

06

2023

PatrickFloff
Sep 11, 2023 • 3:19 p.m. EDT

https://www.short4cams.com/

SEP

11

2023

JohnnyWix
Sep 13, 2023 • 10:38 p.m. EDT

Choice at you uneasy ------ raja bets

SEP

13

2023