Is there an equivalent of Go init function in Crystal or Kemal?

#1

Go language has this notion of init function, which is run once when the server starts. I put code for checking if database tables exist and if not to create them in this function. How can I achieve this in either Crystal or Kemal?

Thank you.

#2

Any code in the top level of a required file contributes to the “main” code.

As long as the require is performed before the server starts listening for connections you should be good to go.

#3

Great! Thanks. That works well.