The backend server portion of Project Mercury
- git
- g++
- cmake
- libpqxx-dev
$ git clone https://github.com/Project-Mercury-App/server.git
$ git submodule update --init mongoose-cpp
$ git submodule update --init pqxx
$ cd server/mongoose-cpp
$ cmake .
$ sudo make install mongoose
$ cd ../pqxx
$ ./configure
$ sudo make install
$ cd ..
$ make
- Make sure your host is exposed to the Internet. I suggest using ngrok. Install ngrok in the "server" directory and run it like so:
$ ./ngrok http 8080
-
Go to Twilio's Phone Numbers management page and click on the phone number you want to use for this server. Then, under Configure -> Messaging -> Request URL, put your server URL (if you're using ngrok, the URL should be displayed in your terminal), and make sure the drop-down menu is on HTTP POST. NOTE: If you are using ngrok, this process will need to be repeated any time you stop your ngrok process and restart it, since it assigns new addresses every time it starts. You can start and stop your server application all you want, but restarting ngrok breaks it.
-
Set your environment variables and start the server application:
$ env pghost={The Address of Your Database} pgdbname={Database Name} pguser={Database Username} pgpassword={Database Password} ./serve.o
Send a text message to the phone number you set up in Twilio. You should see the data your application received come through your terminal, and you'll see a nice little verification message to your phone saying you've successfully contacted the server. Note: At this particular moment, the server's phone number is hard-coded into serve.cpp on line 15. So, change the variable TWILIO_NUM to the number associated with your Twilio account.
$ make