I have hit another stage of feeling like I have accomplished something. I now have my own Parse Server running. It also has a dashboard and cloud code. Plus, (wait for it…), it is also has background jobs!!! The jobs turned out to be considerably less complicated than I thought. It may not be a “proper” resolution, but it works consistently. I will get to that later. I am not going to outline my whole process, but I will share some things that helped me along the way.
My first attempt to set up parse server as outlined by the AWS blog, was successful. However, on subsequent attempts, something was awry. I eventually found out that the elastic beanstalk has at least 2 console designs, and my account at some point was set to the incorrect one. If you click on the “Deply to AWS” button, scroll down the the bottom of the “Create a New Environment” screen and see the following, it will not work. You will have to change your environment back, but be careful, you may wreak havoc on your current account. If you are playing around and you do not need the server for production, if you want to use this method, it may be worth trying it on a new account.
However, if you decide to do it manually, this is what worked for me… Full disclosure, I am on a Mac, your experience may differ. Install the Elastic Beanstalk Command Line Interface, (EB CLI). (I already have Homebrew installed. If you need to do that, go here.)
Skipping over the EB CLI install…
This is something I need to master next time around -> when installing Node.js modules, only install the ones you need! I made the mistake of installing the basic set, because I didn’t know any better, which includes a TON of unneeded modules.
Next bit of Node advice for the noobs, ‘require’ statements and parameters go into the index.js file int the root folder of your project. It took me a while to figure this out.
A HUGE thing I could not get around, was the cloud code file… I was able FTP in, update the file, and see the changes, but they would not be executed. Only updating through the EB deploy function would do it.
These are but some of the hurdles I had to figure out. And the last one that made Parse Server superior to all the other BaaS that I have found so far, background jobs!!! This is how I got around it… Create a function in the cloud code file you want to execute, but do it as a standard function that begin with Parse.Cloud.define
. Go to the Parse docs and find the instructions for curl commands. From what ever system you plan on using to execute the cronjob, open a terminal window and create your command. For ease, navigate back to your home folder with cd ~
. Enter the following command, crontab -e
, this will open a cronjob file. Set the frequency, and paste the curl statement as the command. Save and tada!!! You have background jobs. It may not be the most glamorous solution, but I can attest it works!