From 8196020a242072bdd9e1e4a21c013df45397b62a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20Ant=C3=B4nio=20Farias=20Machado?= <83298718+leandrofars@users.noreply.github.com> Date: Mon, 15 May 2023 10:39:43 -0300 Subject: [PATCH 1/8] feat(devops): automatic deploy front-end [v1] --- .github/github-actions-ec2.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/github-actions-ec2.yml diff --git a/.github/github-actions-ec2.yml b/.github/github-actions-ec2.yml new file mode 100644 index 0000000..439c1ab --- /dev/null +++ b/.github/github-actions-ec2.yml @@ -0,0 +1,31 @@ +name: Deploy Project + +# Trigger deployment only on push to master branch +on: + push: + branches: + - main + +jobs: + deploy: + name: Deploy Front-End + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Deploy to EC2 instance + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST_DNS }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.EC2_SSH_KEY }} + script: | + cd ~/oktopus/frontend + git pull origin master + yarn install && + yarn build && + pm2 restart oktopus + + From d926f8f94ce4e0ac43b094cbf4b153f35ffbecb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20Ant=C3=B4nio=20Farias=20Machado?= <83298718+leandrofars@users.noreply.github.com> Date: Mon, 15 May 2023 13:43:20 +0000 Subject: [PATCH 2/8] fix(devops): add git workflows folder --- .github/{ => workflows}/github-actions-ec2.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{ => workflows}/github-actions-ec2.yml (100%) diff --git a/.github/github-actions-ec2.yml b/.github/workflows/github-actions-ec2.yml similarity index 100% rename from .github/github-actions-ec2.yml rename to .github/workflows/github-actions-ec2.yml From ce5dc9386bdc70e88aaf0b3fdab7595bf38fb7b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20Ant=C3=B4nio=20Farias=20Machado?= <83298718+leandrofars@users.noreply.github.com> Date: Mon, 15 May 2023 13:55:55 +0000 Subject: [PATCH 3/8] fix(devops): pull from main branch, not master --- .github/workflows/github-actions-ec2.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-ec2.yml b/.github/workflows/github-actions-ec2.yml index 439c1ab..b534dd1 100644 --- a/.github/workflows/github-actions-ec2.yml +++ b/.github/workflows/github-actions-ec2.yml @@ -23,7 +23,7 @@ jobs: key: ${{ secrets.EC2_SSH_KEY }} script: | cd ~/oktopus/frontend - git pull origin master + git pull origin main yarn install && yarn build && pm2 restart oktopus From 352afb67517ab29eb4abbd065620ec8ef3b61698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20Ant=C3=B4nio=20Farias=20Machado?= <83298718+leandrofars@users.noreply.github.com> Date: Mon, 15 May 2023 14:05:33 +0000 Subject: [PATCH 4/8] fix(devops): remove "and" shell commands --- .github/workflows/github-actions-ec2.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-actions-ec2.yml b/.github/workflows/github-actions-ec2.yml index b534dd1..cb11ce1 100644 --- a/.github/workflows/github-actions-ec2.yml +++ b/.github/workflows/github-actions-ec2.yml @@ -24,8 +24,8 @@ jobs: script: | cd ~/oktopus/frontend git pull origin main - yarn install && - yarn build && + yarn install + yarn build pm2 restart oktopus From d489245e44c08e17921619ea18f0608c5bc87d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20Ant=C3=B4nio=20Farias=20Machado?= <83298718+leandrofars@users.noreply.github.com> Date: Mon, 15 May 2023 14:28:47 +0000 Subject: [PATCH 5/8] fix(devops): test ssh connection --- .github/workflows/github-actions-ec2.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/github-actions-ec2.yml b/.github/workflows/github-actions-ec2.yml index cb11ce1..cc076fe 100644 --- a/.github/workflows/github-actions-ec2.yml +++ b/.github/workflows/github-actions-ec2.yml @@ -22,10 +22,7 @@ jobs: username: ${{ secrets.USERNAME }} key: ${{ secrets.EC2_SSH_KEY }} script: | - cd ~/oktopus/frontend - git pull origin main - yarn install - yarn build - pm2 restart oktopus + whoami + ls -al From b497a9fa8b131513643ffbe7f97cff9a5b92e08f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20Ant=C3=B4nio=20Farias=20Machado?= <83298718+leandrofars@users.noreply.github.com> Date: Mon, 15 May 2023 14:39:08 +0000 Subject: [PATCH 6/8] chore(devops): ritght workflow settings --- .github/workflows/github-actions-ec2.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-actions-ec2.yml b/.github/workflows/github-actions-ec2.yml index cc076fe..cb11ce1 100644 --- a/.github/workflows/github-actions-ec2.yml +++ b/.github/workflows/github-actions-ec2.yml @@ -22,7 +22,10 @@ jobs: username: ${{ secrets.USERNAME }} key: ${{ secrets.EC2_SSH_KEY }} script: | - whoami - ls -al + cd ~/oktopus/frontend + git pull origin main + yarn install + yarn build + pm2 restart oktopus From 363849ba4e8090002b9439a33a96c7d7306a8ada Mon Sep 17 00:00:00 2001 From: Leandro Farias Machado Date: Thu, 25 May 2023 07:54:32 -0300 Subject: [PATCH 7/8] chore(devops):remove github actions --- .github/workflows/github-actions-ec2.yml | 31 ------------------------ 1 file changed, 31 deletions(-) delete mode 100644 .github/workflows/github-actions-ec2.yml diff --git a/.github/workflows/github-actions-ec2.yml b/.github/workflows/github-actions-ec2.yml deleted file mode 100644 index cb11ce1..0000000 --- a/.github/workflows/github-actions-ec2.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Deploy Project - -# Trigger deployment only on push to master branch -on: - push: - branches: - - main - -jobs: - deploy: - name: Deploy Front-End - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Deploy to EC2 instance - uses: appleboy/ssh-action@master - with: - host: ${{ secrets.HOST_DNS }} - username: ${{ secrets.USERNAME }} - key: ${{ secrets.EC2_SSH_KEY }} - script: | - cd ~/oktopus/frontend - git pull origin main - yarn install - yarn build - pm2 restart oktopus - - From bae078b734e0f2d8d6278930326a18aae15383c7 Mon Sep 17 00:00:00 2001 From: Leandro Farias Machado Date: Sun, 28 May 2023 19:22:44 -0300 Subject: [PATCH 8/8] feat(mochi): allows broker to run with and without tls at the same time --- backend/services/mochi/cmd/main.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/backend/services/mochi/cmd/main.go b/backend/services/mochi/cmd/main.go index 909008a..d5f6d6d 100644 --- a/backend/services/mochi/cmd/main.go +++ b/backend/services/mochi/cmd/main.go @@ -140,20 +140,19 @@ func main() { } } - log.Println("Mqtt Broker is running with TLS") - } else { - if *tcpAddr != "" { - //tcp := listeners.NewTCP("t1", *tcpAddr, &listeners.Config{ - // TLSConfig: tlsConfig, - //}) - tcp := listeners.NewTCP("t1", *tcpAddr, nil) - err := server.AddListener(tcp) - if err != nil { - log.Fatal(err) - } - } - log.Println("Mqtt Broker is running without TLS, (it's dangerous)") + log.Println("Mqtt Broker is running with TLS at port 8883") } + if *tcpAddr != "" { + //tcp := listeners.NewTCP("t1", *tcpAddr, &listeners.Config{ + // TLSConfig: tlsConfig, + //}) + tcp := listeners.NewTCP("t1", *tcpAddr, nil) + err := server.AddListener(tcp) + if err != nil { + log.Fatal(err) + } + } + log.Println("Mqtt Broker is running without TLS at port 1883") if *wsAddr != "" { ws := listeners.NewWebsocket("ws1", *wsAddr, nil)