training.shoppinpal.com
  • Introduction
  • 1. The Ideal Workspace
    • The Perfect Machine
      • For Biz Team
      • For Developers
      • For Designers
    • Setup a machine in the cloud
      • Solution
      • Setup box on Azure
        • Create a machine on Azure
        • Test drive your remote machine
        • Setup Dropbox On Azure
      • Setup box on DigitalOcean
        • Setup UI
        • Shared FileSystem
          • Dropbox
            • Use locally developed node modules in another project
          • sshfs
        • Long Running Sessions
      • Feedback
  • 2. Learning Git
    • Static Code Analysis
  • 3. The Backend
    • Use Containers
    • Setup a loopback project
    • Lockdown
    • Build a better mousetrap
    • The abyss stares back
    • Built-in models
    • Extending built-in models
    • Understanding UserModel
    • Boot Scripts
    • Promises
    • Find roles for current user
    • Loopback Console
    • Current User
  • 4. Multi-tenancy With Loopback
    • What is Multi-Tenancy
    • Architecting with Loopback
    • Define scope for Roles
    • Role Resolvers
    • Access Control For Tenants
    • Better Programming with multi-tenancy
  • 5. The Frontend
    • The Browser
    • Unit Testing
      • Motivation behind this blog
      • How to write a test
      • Karma and Jasmin
      • Writing Tests
    • End-2-End Testing
    • Angular 1.x
    • Angular 2
      • Testing
  • 6. ElasticSearch
    • Better Search with NGram
    • NGram with Elasticsearch
    • Fun with Path Hierarchy Tokenizer
    • Working with Mappings and Analyzers
  • 7. Promises
    • What are Promises
    • Promise Implementations
    • Nuances
    • What should we use
  • 8. Learning Docker
    • Docker Swarm
  • 9. Queues & Workers
    • PHP workers in AWS EBS
    • NodeJS workers in AWS EBS
      • SQS Daemon by AWS
      • SQS Daemon in NodeJS
      • SQS polling by worker
    • Gearman
  • 10. Docker
    • Capabilities
  • Appendix
    • Bug in WebStorm deployments
    • The Perfect Terminal
    • Scalable App Deployment with AWS
    • Chrome Tips & Tricks
    • Host your own Gitbook
    • Gitbook Tips & Tricks
    • How to handle support incidents
    • Dev Resources
    • Debug e2e Tests on CircleCI
    • Logging
    • Authentication Principles
    • Mac
    • nvm
    • Unify testing with npm
      • Debugging Mocha
    • Sequence Diagrams
    • Project Sync via IDE
      • SFTP with WebStorm
      • SFTP with Visual Studio
    • Soft Linking
    • NodeJS Profiling
      • How to find node.js performance optimization killers
    • Setup Packer on Azure
Powered by GitBook
On this page
  • Setup box
  • Shared FileSystem
  1. 1. The Ideal Workspace
  2. Setup a machine in the cloud
  3. Setup box on DigitalOcean
  4. Shared FileSystem

Dropbox

PreviousShared FileSystemNextUse locally developed node modules in another project

Last updated 7 years ago

Setup box

Shared FileSystem

Dropbox

  1. We can use dropbox for efficient 2-way project sync!

    • This approach works for any IDE - atom or webstorm or vscode - they don't have to know about the remote filesystem.

    • This will allow us to write code locally and have the changes show up on the remote box.

      • Adding/deleting files will work

      • File permissions will be properly reflected

      • Configuring selective sync via the dropbox UI will prevent the transfer of bulky dependencies back to your local filesystem

      • such features are often difficult to setup or absent in other sync tools.

    • Tools like SourceTree can simply deal with our local filesystem without any knowledge of the remote filesystem.

  2. Install Dropbox agent

    • for digitalocean 64-bit droplets with Ubuntu OS:

      cd ~ && \
      curl -Lo dropbox-linux-x86_64.tar.gz https://www.dropbox.com/download?plat=lnx.x86_64 && \
      sudo mkdir -p /opt/dropbox && \
      sudo tar xzfv dropbox-linux-x86_64.tar.gz --strip 1 -C /opt/dropbox && \
      /opt/dropbox/dropboxd
  3. Link the machine by copy/pasting the URL from the output window into your browser. Here's a sample of what you'll see:

     This client is not linked to any account...
     Please visit https://www.dropbox.com/cli_link?host_id=xxx
     to link this machine.
  4. Once you are done linking, you will see the following output:

     This computer is now linked to Dropbox. Welcome xxx
    1. Leave the terminal window with dropboxd running in the foreground, as-is.

      • NOTE: dropboxd will start syncing everything in your dropbox account immediately, the next few steps will work to correct this behaviour.

  5. Open a new ssh session with your remote machine and download the dropbox.py command-line tool so we may tell dropboxd to avoid syncing anything other than our code/projects.

     mkdir -p ~/bin && \
     wget -O ~/bin/dropbox.py "http://www.dropbox.com/download?dl=packages/dropbox.py" && \
     chmod 755 ~/bin/dropbox.py && \
     ~/bin/dropbox.py help
  6. Switch to your Dropbox directory and exclude any files that it has begun syncing:

     cd ~/Dropbox/ && ~/bin/dropbox.py exclude add *
  7. Check the status: ~/bin/dropbox.py status

    1. If its still trying to sync then every few minutes, rerun: cd ~/Dropbox/ && ~/bin/dropbox.py exclude add *

    2. Keep running the status check again too: ~/bin/dropbox.py status

    3. After the status check declares: Up to date

      • Run this command one last time to be sure: cd ~/Dropbox/ && ~/bin/dropbox.py exclude add *

    4. Now the contents of your Dropbox directory should be empty: cd ~/Dropbox/ && ls

    5. Feel free to take a look at everything which has been excluded: ~/bin/dropbox.py exclude list

    6. If the directory you want to sync is also excluded, then remove it from exclude list by ~/bin/dropbox.py exclude remove [DIRECTORY] [DIRECTORY]

  8. Now that we've excluded everything known to us, you can place any new code-related projects & folders into dropbox and they will sync between.

    • You probably don't want to host content out of your Dropbox folder, but there's a basic trick for mirroring Dropbox content outside of the Dropbox folder: create a symbolic link.

      Example: ln -s /var/www/foo.com ~/Dropbox/foo.com

      This will cause Dropbox to treat /var/www/foo.com as if it resided inside the Dropbox folder. All other clients will see foo.com as a folder within the Dropbox folder, and will transparently sync across that symlink.

  9. We cannot count on keeping our first ssh session alive forever to run dropboxd so let's

     cd ~ && \
     sudo curl -o /etc/init.d/dropbox https://gist.githubusercontent.com/thisismitch/d0133d91452585ae2adc/raw/699e7909bdae922201b8069fde3011bbf2062048/dropbox && \
     sudo chmod +x /etc/init.d/dropbox && \
     echo DROPBOX_USERS="root" >> /etc/default/dropbox && \
     sudo update-rc.d dropbox defaults && \
     sudo service dropbox start
    • As a safety measure, I thisismitch's gist in case it ever gets taken down.

  10. As a convenience, on your remote box, you can edit ~/.bashrc to add an alias:

     # added on jul 18 2017 by pulkit
     alias dropbox='~/bin/dropbox.py'

    this will let you use shorthand like dropbox status instead of ~/bin/dropbox.py status

  11. If you code using dropbox for sync long enough, you will run into an issue where dropbox will either crash or hang or both because of a limit on maximum number of files it can monitor for changes.

    • If you are lucky then the logs will magically pop-up on your console stating:

        Unable to monitor entire Dropbox folder hierarchy. Please run "echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf; sudo sysctl -p" and restart Dropbox to fix the problem.
        Unable to monitor entire Dropbox folder hierarchy. Please run "echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf; sudo sysctl -p" and restart Dropbox to fix the problem.
    • You can protect against this by what is going on. For example I found out that I had provided significantly less resources than what dropbox recommends!

        # how many watchers have been made available?
        $ cat /proc/sys/fs/inotify/max_user_watches
        8192
      
        # how many watchers have been made available?
        $ sysctl fs.inotify.max_user_watches
        fs.inotify.max_user_watches = 8192
    • Or you could simply go ahead and make the fix:

        # 1. increase the number of watchers
        $ echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf; sudo sysctl -p
        # 2. stop dropbox daemon if its running
        $ ~/bin/dropbox.py stop
        # 3. start the daemon again
        $ /opt/dropbox/dropboxd &
      
        # 4. check the status, it should start humming along again, soon:
        $ dropbox status
        Syncing (22,758 files remaining)
        Indexing 21,025 files...
        Uploading 1,729 files...
      
        $ dropbox status
        Syncing (21,995 files remaining)
        Indexing 19,825 files...
        Uploading 2,166 files...
    • You're welcome ;)

Other References

https://www.dropbox.com/install-linux
https://www.digitalocean.com/community/questions/dropbox-works-with-digitalocean-droplets
set it up as a service
forked
understanding
https://www.digitalocean.com/community/tutorials/how-to-install-dropbox-client-as-a-service-on-ubuntu-14-04
https://www.dropbox.com/install-linux
https://github.com/jolantis/digitalocean-droplet-install-guide#setup-dropbox-sync
http://www.dropboxwiki.com/tips-and-tricks/using-the-official-dropbox-command-line-interface-cli#EXCLUDE
http://www.dropboxwiki.com/tips-and-tricks/install-dropbox-in-an-entirely-text-based-linux-environment#Post-installation