Skip to content

Sync strategies

stop project before switching form strategy

before you switch the sync strategy of your project always stop it with the --clean flag.
This ensures there are no leftover files and volumes.

None

This is the default strategy on Linux.
No special sync is used, it is plain Docker volumes.

NFS

This is the default strategy on MacOS.
Using it on Linux makes no sense, as it would we way slower.

How does it work

To be able to mount projects file with NFS, your system needs to allow exporting those folders as NFS mounts.
These folders are only exported locally, and not exposed for anybody else.

Caveats

  • Only the Launchpad project root (~/.dropsolid-launchpad/projects) is exposed as NFS share.
    Folders outside that folder won't be accessible through an NFS mount by default.

Installation

To be able to mount projects file with NFS, your system needs to allow exporting those project folders as NFS mounts.

Launchpad has a helper command to failitiate those changes.
This command needs to be executed with admin privileges, as it needs to change some system files.

sudo launchpad controlcenter enable_nfs

Mutagen

How does it work

Mutagen is a development utility that allows you to keep folder in sync between 2 environments.
In the specific use case of launchpad, this is done by keeping your local files in sync with a named docker volume, that is used by the docker containers that use those files (e.g. apache and shell)

As most of the time most of the files in a project are read-only, it makes no sense to have a slow and always in sync solution like native Docker bind-mount volumes or NFS volumes.

The whole configuration of what to sync and in what direction is done in the .dlp.yml file, see configuration

More info on the official website

Caveats

  • you can currently only have 1 way syncs from local to the docker volume, not the other way around.
  • you need the double amount of disk space of your project

Installation

  • Download the latest 0.13.x release for your OS and architecture (currently 0.13.1)
  • Unpack the contents of the tarball in /usr/local/bin (or any other direcory on your $PATH), so you have a structure like this:
    1
    2
    3
    ls -al /usr/local/bin/mutagen*
    -rwxr-xr-x@ 1 mattias  staff  17967648 Apr 24 16:24 /usr/local/bin/mutagen
    -rw-r--r--  1 mattias  staff  63068784 Apr 24 16:24 /usr/local/bin/mutagen-agents.tar.gz
    

So leave the mutagen-agents tarball untouched in the same folder.

Configuration

  • Use following snippet as basis for your project.
    Adapt it where needed, e.g.
    • extra exclusions (files folder, sql dumps)
    • extra (2 way) syncs

Add it to your .dlp configuration file (see documentation about what file to use)

version: 1.0
service_settings:
  sync_strategy: mutagen

syncs:
  project:
    src: 
    dest:
    exclude:
      - /docroot/modules/custom
      - /docroot/.htaccess
      - /config  
      - node_modules
    type: one-way-safe
  custom-modules:
    src: docroot/modules/custom
    dest: docroot/modules/custom
    type: two-way-resolved
    create_dest: true
  config:
    src: config
    dest: config
    type: two-way-resolved
symlinks:
  htaccess:
    src: ../etc/drupal/.htaccess
    dest_folder: docroot
    dest_file: .htaccess
version: 1.0
service_settings:
  sync_strategy: mutagen

syncs:
  project:
    src: 
    dest:
    exclude:
      - /docroot/sites/all/modules/custom
      - /docroot/sites/all/modules/features
      - /docroot/.htaccess
      - node_modules
    type: one-way-safe
  custom-modules:
    src: docroot/sites/all/modules/custom
    dest: docroot/sites/all/modules/custom
    type: two-way-resolved
    create_dest: true
  features-modules:
    src: docroot/sites/all/modules/features
    dest: docroot/sites/all/modules/features
    type: two-way-resolved
    create_dest: true
symlinks:
  htaccess:
    src: ../etc/drupal/.htaccess
    dest_folder: docroot
    dest_file: .htaccess

Advanced mode

Launchpad manages the mutagen syncs of a project, but you can check yourself if everything is working as expected.
See mutagen project for all available commands.

The most useful are explained below.

  • mutagen project list
    Shows all syncs in your project

    A more useful shorthand that only shows the name and status is
    mutagen project list | grep -E "(Name|Identifier|Status|--)"
    The Identifier in the output can be used for troubleshooting

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    --------------------------------------------------------------------------------
    --------------------------------------------------------------------------------
    --------------------------------------------------------------------------------
    Name: project
    Identifier: sync_enw4Z7LnOQdyA8GbnHWmdbMUxRGbDnsjWIQNylsM2u9
    Status: Watching for changes
    --------------------------------------------------------------------------------
    Name: custom-modules
    Identifier: sync_DiIUCN2wA2J7959qManIpka3GeXt48N3g8MM0Ibum5x
    Status: Watching for changes
    --------------------------------------------------------------------------------
    Name: config
    Identifier: sync_3xqTAtsmGNkCSMCLKCfUEAfRlnt4DO6DyzN4yQuvmF3
    Status: Watching for changes
    --------------------------------------------------------------------------------
    
  • mutagen project flush and mutagen project reset
    Useful to force the syncs of a project and reset the state

  • mutagen project pause and mutagen project resume
    Useful when doing a lot of file manipulations, where you only want to sync the final result in the end.
    Examples are composer or git operations.

  • mutagen monitor <identifier
    Useful to monitor if a specific sync is working.

Even more advanced mode

Syncing back from a 1 way sync

This part of the documention isn't complete yet, but we're planning to improve / extend it.

Troubleshooting

Sync seems stuck

  • Try to flush and reset the syncs with mutagen project flush and mutagen project reset
  • Find the identifier of the sync that is stuck with mutagen project list
  • Monitor the specific sync to see what is going wrong with mutagen monitor <identifier>