Coder Social home page Coder Social logo

fast-ftp's Introduction

Supercharge your ftp deployments with fast-ftp.

Benchmark

Uploading guestbell.com - ~500 files, 27 directories some 5 levels deep

Time taken Improvement
basic-ftp 217sec 10x
ftp-deploy 197sec 9x
fast-ftp 22sec 1x

Why is it fast?

Ftp doesn't support parallel operations on a single connections. But you can usually spawn many connections. fast-ftp does that + leverages optimized algorithms to increase speed of common tasks like uploading whole directories, deleting whole directories etc.

Standard use-case

Fast ftp was made to accelerate uploading static sites - 1 directory with many files (we also expose api for custom use-cases). We also want the site to work during deployment - to not enter a broken state. How can that happen? If you first delete the whole site and then start uploading or simply just sync directories. Both of these can lead to broken sites if user navigates to it at a wrong moment.

How it works?

  1. Directory is first uploaded to temp ftp directory
  2. Site directory is renamed to old ftp directory
  3. Temp ftp directory is renamed to site directory

This way the downtime is close to 0 and there's not risk of broken sites.

Getting Started

  1. Installation:
npm @guestbell/fast-ftp
# or
yarn @guestbell/fast-ftp
  1. Config Ftp Client

Fast-ftp reads ftp client config (sensitive) from environment variables.

These are required: FTP_HOST FTP_USERNAME FTP_PASSWORD These are optional: FTP_PORT FTP_SECURE

We also support deploy.env config file. Sample follows:

FTP_HOST=example.com
FTP_USERNAME=johndoe
FTP_PASSWORD=secret
  1. Config deployment script

This is done by command line parameters:

These are required: --remote-root Directory path on ftp --local-root Directory path on local machine These are optional: --tmp-root Temporary directory path on ftp - defaults to 'remote-root'+'-tmp' --old-root Old directory path on ftp - defaults to 'remote-root'+'-old' --concurrency How many connections to spawn

  1. Run the script
fast-ftp --remote-root=/sub/example --local-root=/path-to-published

Api

We provide accelerated ftp functions and helpers you can use in your pipeline or node-js projects.

General idea is you first use getClients function to obtain an array of ftp-clients (connections). These are then passed to other functions. Check the main deployment script as an example.

Full api docs here

Created and sponsored by

  • GuestBell - Customer centric online POS for Hotels and short terms stays.

Contributing

  1. Fork it
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

License

MIT

fast-ftp's People

Contributors

peterkottas avatar

Stargazers

Jrson avatar  avatar Rajiv Mounguengue avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.