An open API service indexing awesome lists of open source software.

https://github.com/tomnomnom/symwatch

A tool to run a command when the target of a symlink changes
https://github.com/tomnomnom/symwatch

Last synced: 9 months ago
JSON representation

A tool to run a command when the target of a symlink changes

Awesome Lists containing this project

README

          

# symwatch

Watches a symlink and runs a command when the target of the symlink changes.

[![Build Status](https://travis-ci.org/tomnomnom/symwatch.svg?branch=master)](https://travis-ci.org/tomnomnom/symwatch)

## Installation
```
go get github.com/tomnomnom/symwatch
```

## Usage

```
Usage:
symwatch []

Options:
symlink An absolute or relative path to a symlink
command The command to run when the symlink target changes
pollInterval The number of milliseconds to wait between polling the symlink (default 500)

Notes:
* If the symlink is unreadable for more than 5 attempts the process will exit
* Commands are passed to `sh -c`

Exit Codes:
0 OK
1 Invalid Arguments
2 Invalid Symlink
3 Symlink Went Away

Example:
symwatch /var/www/current 'service apache2 graceful' 500
```

## Motivation

It's a fairly common pattern to use a symlink to point to the current version of
a codebase. Sometimes it's neccesary to restart processes or clear caches when the version
of a codebase changes.

## Why not use inotify?

It's not portable. In particular it does not work if the symlink being polled is on an NFS share.