Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/diogok/semaphore.js
Small widget to tell if server is up or down or slow.
https://github.com/diogok/semaphore.js
Last synced: about 2 months ago
JSON representation
Small widget to tell if server is up or down or slow.
- Host: GitHub
- URL: https://github.com/diogok/semaphore.js
- Owner: diogok
- Created: 2011-11-06T15:45:45.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2012-01-09T16:46:05.000Z (almost 13 years ago)
- Last Synced: 2023-04-13T15:11:48.959Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 93.8 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Semaphore.js
Semaphore.js is light-weight javascript widget that your the status of your server using async calls to it.
It's very useful for ajax apps and single page apps that relies on unstable servers, or that uses third-party services that go offline often.
It shows a very simple widget that indicates if the service is down, up or slow with lights on it.
## Usage
It is very simple to use, just download and load the semaphore.js on your page:
Them start the semaphore at the end of the html, passing your configuration:
semaphore({url: "ok.php"});
The mandatory configuration is a URL that will respond with the server status.
If everything is fine the URL must respond to a GET with a 200 status code and just "ok" as the text. Any other response will be considered an error.
You can test your connection to the database, access third-party services or any other test that your app need to run.
## Options
Semaphore allow a few more options:
- **interval** configures the interval between each semaphore check to the url
- **timeout** configures the timeout to consider when loading the url
- **timealert** configures the timeout to consider the load slow, but not error
- **onerror** a function to be called when server returns an error
- **onsuccess** a function to be called when server returns with success
- **ontimeout** a function to be called on timeout
- **ontimealer** a function to be called on slow responses, but no error yet
- **onlineText** text to display if server is online
- **offlineText** text to display if server is down
- **slowText** text to display if server is slow
- **onlineColor** color to display if server is online
- **offlineColor** color to display if server is down
- **slowColor** color to display if server is slowYou can also style the semaphore using css (but with important statement, for now) all under .x-semaphore class.