Configuring your application to use the persistent file system

Posted by stevenh on 2012-06-22 09:55
OS: All / Any | Product: Stackato | tags: stackato
Question: 

How to configuring a application to use the persistent file system in stackato?

Answer: 

Applies to: Stackato 1.x, 2.x

A persistent file system service allows apps to do the following:

1. Share files across multiple instances of an app
2. Store files that persist if an app is removed (providing the service is not deleted) or if the server is restarted.

Below we will go through how we customized our WordPress installation to use the persistent file system. Before you begin, find out where all the user generated contents are saved. In WordPress, they are stored in wp-content folder.

Therefore we add the following to our stackato.yml::

services:
  fs-wp: filesystem

hooks: 
  post-staging:
    # create wp-content in the shared filesystem
    - mkdir -p "$STACKATO_FILESYSTEM"/wp-content 

    # migrate existing wp-content data into the shared filesystem
    - mv wp-content/* "$STACKATO_FILESYSTEM"/wp-content
    
    # remove unused wp-content directories
    - rm -rf wp-content
  
    # link to wp-content folder in the shared filesystem
    - ln -s "$STACKATO_FILESYSTEM"/wp-content wp-content

That's all! You may have to make modifications to this general approach if your application requires stores user generated content in more than one location.