https://github.com/andmelox/clock-synchronization-project
https://github.com/andmelox/clock-synchronization-project
docker docker-image html javascript syncronization watch
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/andmelox/clock-synchronization-project
- Owner: AndMelox
- Created: 2024-11-12T16:11:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-12T16:24:17.000Z (over 1 year ago)
- Last Synced: 2025-01-22T15:09:46.488Z (about 1 year ago)
- Topics: docker, docker-image, html, javascript, syncronization, watch
- Language: JavaScript
- Homepage:
- Size: 2.35 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Clock Synchronization Project
This project consists of two main components: `node-client` and `node-coordinator`. The goal is to synchronize the clocks of multiple `node-client` instances using a `node-coordinator`.
## Project Structure
node-client/ ├── clock-endpoints.js ├── clock.js ├── Dockerfile ├── index.js ├── logs.js ├── package.json └── public/ ├── index.html └── index.js
node-coordinator/ ├── .env ├── clients-endpoints.js ├── index.js ├── logs.js ├── package.json └── public/ ├── index.html ├── index.js └── socket-server.js
## Setup
### 1. Configure IP Addresses
1. Open the `.env` file in the `node-coordinator` folder and change the IP to your machine's IP address.
2. Open the `index.js` file in the `node-coordinator/public` folder and replace the IP with your machine's IP address:
```javascript
fetch('http://your_ip:5000/createInstance')
fetch('http://your_ip:5000/syncNodes', { method: 'PUT' })
```
### 2. Build and Run Containers
#### node-client
1. Navigate to the `node-client` folder:
```bash
cd node-client
```
2. Build the Docker image:
```bash
docker build -t node-client .
```
#### node-coordinator
1. Navigate to the `node-coordinator` folder:
```bash
cd node-coordinator
```
2. Install dependencies and start the server:
```bash
npm install
npm start
```
### 3. Open in Browser
Open your browser and go to `http://your_ip:5000` to view the `node-coordinator` interface.
## Features
- **node-client**: Provides endpoints to get and update the clock of each instance.
- **node-coordinator**: Coordinates clock synchronization across multiple `node-client` instances.
## Endpoints
### node-client
- `GET /clock`: Retrieves the current time of the clock.
- `PUT /clock`: Updates the clock with a specified adjustment.
### node-coordinator
- `POST /clients`: Registers a new client.
- `GET /createInstance`: Creates a new `node-client` instance.
- `PUT /syncNodes`: Synchronizes the clocks of all registered instances.
## Notes
- Ensure that Docker is installed and running on your machine.
- Make sure the configured IP addresses are accessible on your network.
## Authors
[
](https://github.com/AndMelox)
[
](https://github.com/sebastian11020)
[
](https://github.com/SamVargasGit)
## 🔗 Contact Links