forked from osmosis-labs/osmosis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
3,920 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM python:3.8-slim | ||
|
||
COPY . . | ||
RUN apt-get update && apt-get install -y libpq-dev gcc | ||
RUN pip install -r requirements.txt | ||
|
||
CMD python main.py sync --db postgres:[email protected]:5432/localosmosis -s 172.18.0.31:9092 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
# Flusher | ||
|
||
## About | ||
|
||
**Flusher** is a simple program implemented in Python to consume Kafka messages from a queue and load them into the | ||
Postgres database | ||
|
||
## Setup instructions for Ubuntu users | ||
|
||
For Ubuntu users, to install dependencies including Java, Postgres and Kafka | ||
|
||
```shell | ||
sudo apt update | ||
sudo apt upgrade --yes | ||
|
||
sudo apt install default-jdk | ||
cd $HOME | ||
curl "https://downloads.apache.org/kafka/3.3.2/kafka_2.13-3.3.2.tgz" -o kafka.tgz | ||
mkdir $HOME/kafka && cd $HOME/kafka | ||
tar -xvzf $HOME/kafka.tgz --strip 1 | ||
``` | ||
|
||
Config the downloaded zookeeper and kafka. Edit the file | ||
|
||
```shell | ||
vim $HOME/kafka/config/server.properties | ||
``` | ||
|
||
With the following values | ||
|
||
```toml | ||
log.dirs=/home/ubuntu/kafka/logs | ||
delete.topic.enable = true | ||
message.max.bytes = 52428800 | ||
replica.fetch.max.bytes = 52428800 | ||
``` | ||
|
||
Next, let's create a system service for zookeeper. Create the service file | ||
|
||
```shell | ||
sudo vim /etc/systemd/system/zookeeper.service | ||
``` | ||
|
||
With the following code | ||
|
||
```shell | ||
[Unit] | ||
Requires=network.target remote-fs.target | ||
After=network.target remote-fs.target | ||
|
||
[Service] | ||
Type=simple | ||
User=ubuntu | ||
ExecStart=/home/ubuntu/kafka/bin/zookeeper-server-start.sh /home/ubuntu/kafka/config/zookeeper.properties | ||
ExecStop=/home/ubuntu/kafka/bin/zookeeper-server-stop.sh | ||
Restart=on-abnormal | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
``` | ||
|
||
In the similar manner, create a service for kafka | ||
|
||
```shell | ||
sudo vim /etc/systemd/system/kafka.service | ||
``` | ||
|
||
With the following code | ||
|
||
```shell | ||
[Unit] | ||
Requires=zookeeper.service | ||
After=zookeeper.service | ||
|
||
[Service] | ||
Type=simple | ||
User=ubuntu | ||
ExecStart=/bin/sh -c '/home/ubuntu/kafka/bin/kafka-server-start.sh /home/ubuntu/kafka/config/server.properties > /home/ubuntu/kafka/kafka.log 2>&1' | ||
ExecStop=/home/ubuntu/kafka/bin/kafka-server-stop.sh | ||
Restart=on-abnormal | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
``` | ||
|
||
Finally, we can start both services | ||
|
||
```shell | ||
sudo systemctl enable zookeeper | ||
sudo systemctl enable kafka | ||
sudo systemctl daemon-reload | ||
|
||
sudo systemctl start zookeeper | ||
sudo systemctl start kafka | ||
``` | ||
|
||
## Setup instructions for macOS users | ||
|
||
For macOS users, to install dependencies including Java, Postgres and Kafka | ||
|
||
```shell | ||
brew cask install java | ||
brew install postgresql | ||
brew install kafka | ||
``` | ||
Start the zookeeper service to provide an in-sync view of Kafka cluster, topics and messages | ||
|
||
```shell | ||
brew services start zookeeper | ||
``` | ||
|
||
Start the postgresql service to provide the database server | ||
|
||
```shell | ||
brew services start postgresql | ||
``` | ||
|
||
Start the kafka service to provide a message queue for the indexer node | ||
|
||
```shell | ||
brew services start kafka | ||
``` | ||
|
||
Now make sure python3 venv is installed | ||
|
||
```shell | ||
python3 -m pip install --user virtualenv | ||
``` | ||
|
||
Then run this command to activate the virtual environment and install python dependencies | ||
|
||
```shell | ||
python3 -m venv venv && source venv/bin/activate | ||
pip install -r requirements.txt | ||
``` | ||
Note that if you encounter an openssl problem while installing dependencies, simply run | ||
|
||
```shell | ||
brew install openssl && export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/ | ||
``` | ||
|
||
## Running Flusher | ||
|
||
Before running the flusher, do not forget to activate the python virtual environment | ||
|
||
```shell | ||
cd flusher | ||
source venv/bin/activate | ||
``` | ||
|
||
And use this command to start flusher | ||
|
||
```shell | ||
python3 main.py sync --db <DB_URL> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import flusher.init | ||
import flusher.sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import click | ||
|
||
|
||
@click.group() | ||
def cli(): | ||
"""flusher utility program.""" | ||
pass |
Oops, something went wrong.