Objective-C in the Cloud

Terrasphere

Terrasphere is a simple application server written in Objective-C.

To be more precise: Terrasphere is only a (lightweight) UI for terrasphered (the actual application server).

Tasks

Although an application server has many tasks, this document only highlights the most important tasks that are relevant for you.

Unified Access

When a cloud application is launched it creates an HTTP server on a random port. This is very inconvenient if you want to use your cloud application (for example: you usually test your cloud application locally and thus you need to communicate with your cloud application). You would have to determine the port of your cloud application before you can actually use it. In contrast, Terrasphere is always running on port 10000. If you send a request to Terrasphere it will forward it to the correct cloud application. Terrasphere can do that because it knows about all cloud applications. This brings us to another thing Terrasphere is doing for you: Forwarding.

Forwarding

Terrasphere knows which cloud applications are currently running and it also knows their ports. If a request comes in, Terrasphere looks at the subdomain of the request's host and finds out which cloud application handles requests for this specific path component. If Terrasphere found a cloud application that can handle the request it forwards the HTTP request to that cloud application.

Updating and Bootstrapping

The whole point of Terrasphere is that you can test your cloud applications locally before pushing them to Objective-Cloud. Of course you want to test your cloud application in the same environment that it will be used when running it on Objective-Cloud. Basically, you have to mirror Objective-Cloud on your Mac. Since Objective-Cloud is a complex software we have extracted the most important components and packed them in an installer. When you install Terrasphere you also install a scaled down and simplified version of Objective-Cloud on your Mac. In addition Terrasphere tries to keep your local copy of Objective-Cloud up to date: When we deploy a new version of Objective-Cloud to our servers we also update Terrasphere. In turn Terrasphere will automatically ask you to download and execute the installer again if appropriate.

Gotchas

Terrasphere works great at long you are only working on one cloud application at a time. Each cloud application has a name. When a cloud application is deployed and a request comes in, you have to specify the name of the cloud application as part of the subdomain. For example https://helloworld.obcl.io identifies the cloud application called helloworld. As long you are working locally you make your request to localhost and localhost cannot have subdomains by default. This is why there can only ever be one cloud application locally. There are ways around this though: You can modify your /etc/hosts file for example.