Verified Commit f46cd3e1 authored by Aral Balkan's avatar Aral Balkan
Browse files

Closes #67: implement 5-second timeout for rsync connection attempts

(The actual connection timeout specified is the SSH ConnectionTimeout option used by rsync.)
parent db25b9e4
......@@ -391,6 +391,8 @@ $ site my-local-folder --sync-to=me@my.site:my-remote-folder --sync-folder-and-c
The above command will result in the following directory structure on the remote server: _/home/me/my-remote-folder/my-local-folder_. It also demonstrates that if you specify a relative folder, Site.js assumes you mean the folder exists in the home directory of the account on the remote server.
(As of 15.4.0) If the sync command cannot connect in 5 seconds, it will time out. If this happens, check that you have the correct host and account details specified. If you do, there might be a problem with your connection.
#### Live Sync
With the Live Sync feature, you can have Site.js watch for changes to your content and sync them to your server in real-time (e.g., if you want to live blog something or want to keep a page updated with local data you’re collecting from a sensor).
......
......@@ -21,7 +21,7 @@ const Graceful = require('node-graceful')
const RsyncWatcher = require('./RsyncWatcher')
const ensure = require('./ensure')
const clr = require('../../lib/clr')
const { small } = require('@small-tech/cross-platform-hostname')
function sync (options) {
// Check for prerequisites (sync functionality requires rsync to be installed.)
......@@ -83,7 +83,7 @@ function sync (options) {
_[30] = 'Timeout in data send/receive'
_[35] = 'Timeout waiting for daemon connection'
_[127] = 'Rsync not found; please run site enable --sync'
_[255] = `SSH error while connecting to ${clr(options.host, 'cyan')} (is this hostname/SSH certificates correct?)`
_[255] = `SSH error while connecting to ${clr(options.host, 'cyan')} is this hostname/SSH certificates correct?`
// Scrape the error code from the error string (not ideal but it’s all
// we have to work with).
......@@ -94,7 +94,6 @@ function sync (options) {
const errorMessage = _[errorCode]
if (typeof errorMessage !== 'undefined') {
console.log(`\n ❌ ${clr('❨site.js❩ Error:', 'red')} ${errorCode} (${errorMessage})\n`)
console.log(error)
process.exit(1)
}
}
......@@ -150,7 +149,9 @@ function sync (options) {
// We don't need to rewrite the key with Linux line endings since this is our convention and so
// we expect that the key was written out from Node with the correct line endings to begin with.
console.log(` 🔑 ❨site.js❩ Using site-specific SSH key: ${ed25519KeyBasedOnFolderName}`)
rsyncOptions.sync.rsyncOptions.rsh = `ssh -i ${ed25519KeyBasedOnFolderName}`
rsyncOptions.sync.rsyncOptions.rsh = `ssh -i ${ed25519KeyBasedOnFolderName} -o ConnectTimeout=5`
} else {
rsyncOptions.sync.rsyncOptions.rsh = `ssh -o ConnectTimeout=5`
}
// Add Windows support if necessary.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment