I can't seem to figure out how to get my express server to run a simple function when the server starts up. Where is the appropriate place to call a function to run on server startup, and the proper syntax?
I have the function in my routes file as exports.myFunction = function() { code here};
I've tried sticking it in the app.configure block as routes.myFunction. I've tried changing it in routes to just be myfunction() { code}
, then calling it in the configure block as routes.myfunction()
, no luck there either. The function needs to stay in the file containing my routes since it alters some global variables there.
I know it's some stupidly simple syntax thing, but I can't seem to find any hints here or on google. Much thanks for any help!