Skip to content

Commit

Permalink
feat: add support for --timeout in rsync options for large sites
Browse files Browse the repository at this point in the history
  • Loading branch information
wilr committed May 29, 2024
1 parent 5f080a5 commit f61a260
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 134 deletions.
58 changes: 28 additions & 30 deletions CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ If you are looking for an example configuration to get you started, look in [`RE

Beam has the following workflow assumptions:

* You are using a version control system (Git is the only supported VCS at this time).
* You want to sync the head of a branch or a specific commit to a server.
* You want to be very sure about what is going to happen when you sync
* You may want to exclude files and folders from the deployment
* You may have multiple servers with different purposes (ie. testing and live)
* You may want to run custom commands at different stages of deployment, locally and on the target server.
* You want to do all of this with a command as simple as `beam up live`
- You are using a version control system (Git is the only supported VCS at this time).
- You want to sync the head of a branch or a specific commit to a server.
- You want to be very sure about what is going to happen when you sync
- You may want to exclude files and folders from the deployment
- You may have multiple servers with different purposes (ie. testing and live)
- You may want to run custom commands at different stages of deployment, locally and on the target server.
- You want to do all of this with a command as simple as `beam up live`

As well as 'beaming' up, `beam` can also 'beam' down; synchronising your working copy with what's on a server. You can also do a working copy `beam up`, send a specific branch, and do a dry-run to simulate a sync. For a full list of options run `beam up --help`.

Expand All @@ -33,7 +33,6 @@ To give a clear picture of what a `beam up my-target` does with no command line
1. Run commands defined as `phase: post`, `location: target` in the deployment location on the target server
1. Clean up the temporary export location


## Servers

"servers": {
Expand All @@ -53,32 +52,33 @@ Servers are individual, named deployment targets. When using `beam up` or `beam

**The following properties are required for each defined server:**

* `host` - Host name or IP address of the server
* `webroot` - Path to the deployment directory on the server. Relative paths are relative to the user's home directory. A trailing slash is optional.
- `host` - Host name or IP address of the server
- `webroot` - Path to the deployment directory on the server. Relative paths are relative to the user's home directory. A trailing slash is optional.

### Optional properties
* `user` - User to log into the server with
* `type` *(string: rsync)* - Transfer method to use with the server. This must be one of `rsync`, `ftp`, and `sftp` (FTP over SSH).
* `branch` *(string)* - Branch to lock this server to. When specified, a `beam up` to this server will always send this branch, regardless of the currently checked out branch and the `--ref` and `--working-copy` flags. This is useful for ensuring that only one branch can be deployed to, for example, your production server. Any git branch is valid here, including remote branches like `remotes/origin/master`.

- `user` - User to log into the server with
- `type` _(string: rsync)_ - Transfer method to use with the server. This must be one of `rsync`, `ftp`, and `sftp` (FTP over SSH).
- `branch` _(string)_ - Branch to lock this server to. When specified, a `beam up` to this server will always send this branch, regardless of the currently checked out branch and the `--ref` and `--working-copy` flags. This is useful for ensuring that only one branch can be deployed to, for example, your production server. Any git branch is valid here, including remote branches like `remotes/origin/master`.

### (S)FTP properties

When `type` is set to 'ftp' or 'sftp', a number of FTP specific properties are available:

**FTP & SFTP:**

* `password` *(string)* - Password to connect with. Beam will prompt for a password where one is not specified in the config.
- `password` _(string)_ - Password to connect with. Beam will prompt for a password where one is not specified in the config.

**FTP only:**

* `passive` *(boolean: false)* - Run the FTP session in passive mode.
* `ssl` *(boolean: false)* - Make the FTP connection over SSL (FTPS)
- `passive` _(boolean: false)_ - Run the FTP session in passive mode.
- `ssl` _(boolean: false)_ - Make the FTP connection over SSL (FTPS)

### Rsync properties

* `sshpass` *(boolean: false)* - Use the program [`sshpass`](http://sourceforge.net/projects/sshpass/) to enter your SSH password automatically when using password authentication. With this option enabled, Beam will prompt for an SSH password once instead of an SSH client prompting for each new connection. Key-based authentication is reccommeded, though this may not suit everyone. To use this option you will need to have the `sshpass` program accessible on your path.
* `syncPermissions` *(boolean: true)* - Sync permissions (file mode) of transferred files and directories. Set this to `false` to let the target filesystem control file mode. This is on by default for backwards compatibility.

- `sshpass` _(boolean: false)_ - Use the program [`sshpass`](http://sourceforge.net/projects/sshpass/) to enter your SSH password automatically when using password authentication. With this option enabled, Beam will prompt for an SSH password once instead of an SSH client prompting for each new connection. Key-based authentication is reccommeded, though this may not suit everyone. To use this option you will need to have the `sshpass` program accessible on your path.
- `syncPermissions` _(boolean: true)_ - Sync permissions (file mode) of transferred files and directories. Set this to `false` to let the target filesystem control file mode. This is on by default for backwards compatibility.
- `timeout` _(int: 120)_ - Timeout for rsync call.

## Exclude

Expand All @@ -96,7 +96,6 @@ When using the `rsync` deployment method (default), patterns are passed directly

When using (S)FTP, exclusion patterns are handled internally by beam (crudely relative to rsync) and follow the basic rules of rsync's path matching.


## Commands

"commands": [
Expand Down Expand Up @@ -126,25 +125,24 @@ Note that running commands on a target requires an SSH connection to the target.

**Each command must define:**

* `command` - Command to execute. This can be is anything you would normally type on a shell
* `phase` - Phase of deployment to execute the command in: `pre` or `post` upload to the target
* `location` - What machine to run the command on: `local` or `target`
- `command` - Command to execute. This can be is anything you would normally type on a shell
- `phase` - Phase of deployment to execute the command in: `pre` or `post` upload to the target
- `location` - What machine to run the command on: `local` or `target`

**Additionally, the following can be specified:**

* `servers` *(array)* - A list of server configs by name that a command is limited to. When this option is defined, the command will only run on the specified servers. When not defined a command will run when deploying to any server.
* `tag` *(string)* - A tag for use with the `--tags (-t)` option. Tagged commands are not run unless their tag is specified when `beam` is run. Multiple commands can have the same tag.
* `required` *(boolean: false)* - Specifies that a command is required for the deployment to complete successfully. Required commands do not prompt when `--command-prompt` is used, are run regardless of tags, and beam will abort if a required command fails.
* `tty` *(boolean: false)* - Whether the command should be run in a terminal (TTY) environment. Any command that requires user input/interaction will need this option enabled to work correctly. When set to true, the i/o streams (stdin, stderr, stdout) of the command process are connected to the current terminal instead of being managed internally by `beam`.

- `servers` _(array)_ - A list of server configs by name that a command is limited to. When this option is defined, the command will only run on the specified servers. When not defined a command will run when deploying to any server.
- `tag` _(string)_ - A tag for use with the `--tags (-t)` option. Tagged commands are not run unless their tag is specified when `beam` is run. Multiple commands can have the same tag.
- `required` _(boolean: false)_ - Specifies that a command is required for the deployment to complete successfully. Required commands do not prompt when `--command-prompt` is used, are run regardless of tags, and beam will abort if a required command fails.
- `tty` _(boolean: false)_ - Whether the command should be run in a terminal (TTY) environment. Any command that requires user input/interaction will need this option enabled to work correctly. When set to true, the i/o streams (stdin, stderr, stdout) of the command process are connected to the current terminal instead of being managed internally by `beam`.

## Import

"import": [
"~/configs/another-beam-config.json",
"http://example.com/silverstripe-config.json"
]

The `import` config option is an array of filenames that provides a way to merge multiple beam.json files together. Using imports, common settings can be used across multiple projects without duplication and managing shared options becomes easier.

The values in `import` can be anything accepted by PHP's `file_get_contents`, including but not limited to HTTP URLs and local file paths. A tilde at the start of a path is replaced with the path to the current user's home directory. Imports are fetched recursively (ie. imported configs can import further configs) with each unique path being fetched only the first time it appears.
Expand Down Expand Up @@ -179,4 +177,4 @@ Beam offers some support for using dynamic values in configs by way of token rep
<dd>The username of the user running the beam process
<dt>%%user_identity%%
<dd>The full name and email address of the current user according to the VCS. Eg. <code>Joe Smith &lt;[email protected]&gt;</code>
</dl>
</dl>
Loading

0 comments on commit f61a260

Please sign in to comment.