SSH in Stackato
by Sridhar Ratnakumar

Sridhar Ratnakumar, February 28, 2012

A "run" command for Cloud Foundry

Cloud Foundry lacks support for running arbitrary commands. Being able to run arbitrary commands is essential when processing data outside of the web application request-response cycle. "run" is essential to perform tasks like Django's admin user creation (and changing its password) or populating a database from a Twitter stream.

Stackato's old "run" command

Since the first release of Stackato, we included a basic "stackato run" command to do this. As it made HTTP calls to the Cloud Controller and then to the DEA, it was somewhat limited and unreliable. Interaction was not possible and long running scripts would be killed off by the various timeouts in the HTTP stack.

LXC makes "run" secure and easy

Once we added support for LXC, it made no sense to continue using the old "run" implementation, so we added full SSH support for deployed applications. As applications are isolated by LXC - meaning, they run in their virtual Linux instance - running "stackato ssh app-name" is equivalent to SSH'ing to your application container, and you have full sudo rights. Things like sudo apt-get install libfoo-dev1 become possible. Indeed, the recently added requirements feature allows installation of arbitrary system packages through this mechanism.

"stackato run" is now an alias for "stackato ssh".

When is "run" useful?

  • Running framework-specific commands. Django has several management commands ranging from syncdb (initializes database; creates first super-user), dumpdata (export database to specified format) to shell (starts the python interactive shell).

  • Running one-off application-specific tasks. Our code site includes several tasks to initialiaze data for PyPM Index, PPM Index and other components. These are best run once, after the site was deployed for first time.

  • Inspecting the application environment. Maybe you just want to navigate around the application files. If stackato files is too limited for this purpose, run stackato ssh. With great power comes great responsibility, so be careful not to tamper with important files.

  • Navigating and modifying files in the persistent file service.

  • System maintenace tasks such as routine/manual clean-up and monitoring. For example, you may schedule periodic tasks outside of Stackato at status.${yourcompany}.com to monitor the health of your application by running various commands. The use of a separate 'status' web app, deployed to a different cloud/IaaS environment, is used by several public service providers such as Twitter, GitHub.


Here are a few sample applications that make use of the new "run" command, based on SSH:

  • prezbuzz - a script to update Twitter data.

  • django-gtd - Django; initialize database using "syncdb", migrate tables using South's "migrate".

  • celery-demo - queue tasks for Celery workers, and wait for the response

Subscribe to ActiveState Blogs by Email

Share this post:

Category: stackato
About the Author: RSS

Sridhar Ratnakumar is a senior Python developer at ActiveState where he works tirelessly to ensure that ActivePython is the world's highest quality Python distribution. He's been developing on Python since 2003 and is the author of various Python modules, including pyrtm and applib. He earned his software development stripes at Amazon and Microsoft.