Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/ezralazuardy/adcs

πŸ–₯️ Automated Autonomous Drone Communication System Manager
https://github.com/ezralazuardy/adcs

inertiajs laravel mqtt vue

Last synced: 23 days ago
JSON representation

πŸ–₯️ Automated Autonomous Drone Communication System Manager

Awesome Lists containing this project

README

        


Laravel


Docker


Node Version


Yarn Version


PHP Version


PWA Support

# πŸ–₯️ adcs

A manager and backend server for Automated Autonomous Drone Communication System.

πŸ”¨ Built with [Laravel Jetstream](https://jetstream.laravel.com) and [Inertia.js](https://inertiajs.com) for Single Page
Application builder ([PWA](https://web.dev/progressive-web-apps) enabled).

⚑ Supercharged with [Laravel Octane](https://laravel.com/docs/8.x/octane) for massive server performance boost.

> ⚠️ **Important Notes**
>
> - [Swoole](https://www.swoole.co.uk) need to be installed in the server in order to use Laravel Octane.
> - Please respect the Laravel Octane [rules and limitations](https://laravel.com/docs/8.x/octane#dependency-injection-and-octane) in order to avoid memory leaks.

### πŸ€– Runtime Components

In order to test the ADCS functionalities, you need to run several component instance based on
this [repository](https://github.com/ezralazuardy/adcs-runtime). Based on the given topology below, you need to run the
Drone instances (min. 1 instance) and the Commander Server instance.

### πŸ—ΊοΈ Topology

![ADCS Software Topology](https://user-images.githubusercontent.com/24422019/144341602-86e17ae4-3991-470f-9d56-b5dd3ac18941.png)


## βœ… Technologies & Standards

1. [Laravel](https://laravel.com/docs/8.x) `v8`
2. [Laravel Eloquent](https://laravel.com/docs/8.x/eloquent)
3. [Laravel Events](https://laravel.com/docs/8.x/events)
4. [Laravel Queues](https://laravel.com/docs/8.x/queues)
5. [Laravel Task Scheduling](https://laravel.com/docs/8.x/scheduling)
6. [Laravel Mix](https://laravel.com/docs/8.x/mix)
7. [Laravel Broadcasting](https://laravel.com/docs/8.x/broadcasting)
8. [Laravel Jetstream](https://jetstream.laravel.com)
9. [Laravel Fluent](https://github.com/lepikhinb/laravel-fluent)
10. [Laravel Octane](https://laravel.com/docs/8.x/octane) optional
11. [Laravel Cloudflare](https://github.com/monicahq/laravel-cloudflare) optional
12. [Laravel Sail](https://laravel.com/docs/8.x/sail) optional
13. [PHP PSR2 Coding Style Standard](https://www.php-fig.org/psr/psr-2)
14. [PHPStan](https://phpstan.org/) (with [Larastan](https://github.com/nunomaduro/larastan) extension)
15. [Inertia.js](https://inertiajs.com)
16. [Vue.js](https://vuejs.org)
17. [Webpack](https://webpack.js.org)
18. [Supercronic](https://github.com/aptible/supercronic)
19. [Supervisor](http://supervisord.org/index.html)
20. [MySQL](https://dev.mysql.com) `v5`
21. [PHP MQTT](https://github.com/php-mqtt/client)
22. [Pusher](https://pusher.com)
23. [Swoole](https://www.swoole.co.uk) optional
24. [Github Action CI/CD](https://github.com/features/actions) optional
25. [Docker](https://www.docker.com) optional
26. [Sentry](https://sentry.io) optional
27. [Yarn](https://yarnpkg.com) optional


## πŸ‘¨β€πŸ’» Getting Started

Ikuti salah satu dari langkah berikut untuk melakukan deploy aplikasi pada tahap **development**.

### πŸ‹ Docker

Langkah instalasi dockerized application dengan β›΅ Laravel Sail untuk memudahkan proses deployment aplikasi

#### βœ”οΈ Requirement

1. PHP `v8.0`
2. Composer `v2`
3. [Docker](https://www.docker.com)
- [Docker for Windows](https://docs.docker.com/docker-for-windows/install) `v4.0.1`
- [Docker for Linux](https://docs.docker.com/engine/install) `v4.0.1`
- [Docker for Mac](https://docs.docker.com/docker-for-mac/install) `v20.10`

#### πŸ–₯️ Installation

1. Clone repository ini ke local environment, lalu checkout ke `development` branch
2. Buat file `.env` dengan menyalin file `.env.example`, lalu konfigurasikan seperti berikut:
- Ubah `APP_ENV` menjadi `local`
- Ubah `APP_DEBUG` menjadi `true`
3. `composer i --ignore-platform-reqs`
4. `vendor/bin/sail up`

> #### πŸ“ Informasi
> - Jika menggunakan OS Windows, jalankan Laravel Sail dalam [Windows WSL v2](https://ubuntu.com/wsl)
> - Akses aplikasi via web pada alamat `http://127.0.0.1`
> - Alamat URL dan port aplikasi yang digunakan Laravel Sail sesuai konfigurasi pada `.env`

> #### πŸ‘Œ Rekomendasi
> - Pelajari perintah **Laravel Sail** pada dokumentasi [berikut](https://laravel.com/docs/8.x/sail)

### 🏑 Self Hosted

Langkah tradisional untuk melakukan deploy aplikasi pada local atau self-hosted environment

#### βœ”οΈ Requirement

1. PHP `v8.0`
2. Composer `v2`
3. MySQL Server `v5.7`
4. NodeJS `v16`
5. Yarn `v1`
6. [Laravel Homestead](https://laravel.com/docs/8.x/homestead)
/ [Laravel Valet](https://laravel.com/docs/8.x/valet) optional

#### πŸ–₯️ Installation

1. Buat MySQL database untuk aplikasi:
- `mysql -u root -p`
- `create database adcs;`
- `create user 'adcs'@'localhost' identified by 'adcs';`
- `grant all privileges on adcs.* to 'adcs'@'localhost';`
- `flush privileges;`
- `exit;`
2. Clone repository ini ke local environment, lalu checkout ke `development` branch
3. Buat file `.env` dengan menyalin file `.env.example`, lalu konfigurasikan seperti berikut:
- Ubah `APP_ENV` menjadi `local`
- Ubah `APP_DEBUG` menjadi `true`
4. `composer i`
5. `php artisan app:install`

> #### πŸ“ Informasi
> - Pastikan ekstensi PHP yang dibutuhkan Laravel `v8` sudah terpasang pada local development environment, sesuai dokumentasi [berikut](https://laravel.com/docs/8.x/deployment)

> #### πŸ’‘ Opsional
> - Gunakan `php artisan serve` untuk membuka aplikasi via PHP Built-in Web Server
> - Gunakan `php artisan queue:work database` untuk testing fitur [Queues](https://laravel.com/docs/8.x/queues)
> - Gunakan `php artisan schedule:run` untuk testing fitur [Task Scheduling](https://laravel.com/docs/8.x/scheduling)
> - Gunakan `php artisan optimize` saat setelah proses development untuk mempercepat performa aplikasi

> #### πŸ‘Œ Rekomendasi
> - Gunakan `composer dev` untuk optimalisasi Laravel Intellisense pada IDE anda
> - Gunakan `composer lint` untuk menjalankan PHP Linter (Static Code Analaysis)
> - Gunakan local development environment seperti [Laravel Homestead](https://laravel.com/docs/8.x/homestead) / [Laravel Valet](https://laravel.com/docs/8.x/valet)


## πŸš€οΈ Production Deployment

Ikuti langkah berikut ini untuk melakukan deploy aplikasi pada tahap **staging** atau **production**.

### 🏑 Self Hosted

Langkah tradisional untuk melakukan deploy aplikasi pada local atau self-hosted environment

#### βœ”οΈ Requirement

1. PHP `v8.0`
2. Composer `v2`
3. MySQL Server `v5.7`
4. NodeJS `v16`
5. Yarn `v1`
6. [Nginx](https://nginx.org/en/download.html) / [Apache2](https://httpd.apache.org/download.cgi)
/ [LiteSpeed](https://openlitespeed.org/Downloads/)
7. [Supercronic](https://github.com/aptible/supercronic)
8. [Supervisor](http://supervisord.org/index.html)

#### πŸ–₯️ Installation

1. Buat MySQL database untuk aplikasi:
- `mysql -u root -p`
- `create database adcs;`
- `create user 'adcs'@'localhost' identified by 'adcs';`
- `grant all privileges on adcs.* to 'adcs'@'localhost';`
- `flush privileges;`
- `exit;`
2. Clone repository ini ke server, lalu checkout ke `main` branch
3. Buat file `.env` dengan menyalin file `.env.example`, lalu konfigurasikan seperti berikut:
- Ubah `APP_ENV` menjadi `production`
- Ubah `APP_DEBUG` menjadi `false`
4. `composer i --no-dev`
5. `php artisan app:install`
6. Konfigurasikan Web Server dengan path **Document Root** mengarah ke lokasi direktori `public` pada proyek
7. Install **redis-server** untuk aplikasi:
- `sudo apt install redis-server`
- `sudo nano /etc/redis/redis.conf`, lalu ubah `supervised no` menjadi `supervised systemd`
- `sudo service redis-server restart`
8. Install **supercronic** untuk aplikasi:
- `sudo apt install snap`
- `sudo snap install go`
- `go get -d github.com/aptible/supercronic`
- `cd ~/go/pkg/mod/github.com/aptible/supercronic@v`

> Ubah `` ke versi terakhir supercronic sesuai laman [berikut](https://github.com/aptible/supercronic/releases)


- `go mod vendor`
- `go install`
- `source /etc/profile`
- Verifikasi instalasi supercronic dengan perintah `supercronic`
- Siapkan cronjob untuk aplikasi:
```bash
rm -rf ~/supercronic && \
sudo mkdir ~/supercronic && \
sudo touch ~/supercronic/adcs.cron && \
sudo echo "path=/var/www/adcs" >> ~/supercronic/adcs.cron && \
sudo echo "* * * * * php $path/artisan schedule:run >> /dev/null 2>&1" >> ~/supercronic/adcs.cron && \
sudo echo "0 1 * * * rm -rf $path/storage/logs/laravel.log && touch $path/storage/logs/laravel.log" >> ~/supercronic/adcs.cron && \
sudo echo "0 1 * * * rm -rf $path/storage/logs/adcs-cron.log && touch $path/storage/logs/adcs-cron.log" >> ~/supercronic/adcs.cron && \
sudo echo "0 1 * * * rm -rf $path/storage/logs/adcs-worker.log && touch $path/storage/logs/adcs-worker.log" >> ~/supercronic/adcs.cron && \
sudo echo "0 1 * * * rm -rf $path/storage/logs/adcs-octane.log && touch $path/storage/logs/adcs-octane.log" >> ~/supercronic/adcs.cron && \
sudo echo "0 1 * * * rm -rf $path/storage/logs/nginx-access.log && touch $path/storage/logs/nginx-access.log" >> ~/supercronic/adcs.cron && \
sudo echo "0 1 * * * rm -rf $path/storage/logs/nginx-error.log && touch $path/storage/logs/nginx-error.log" >> ~/supercronic/adcs.cron
```
> Sesuaikan path `/var/www/adcs` dengan lokasi direktori proyek
9. Install **supervisor** untuk aplikasi:
- `sudo apt install supervisor`
- `sudo chown -R www-data:www-data /var/www/`
- `nano /etc/supervisor/conf.d/adcs-supervisor.conf`
- Masukkan konfigurasi berikut:

```
[supervisord]
nodaemon=false
logfile=/dev/null
logfile_maxbytes=0
pidfile=/run/supervisord.pid

[program:adcs-cron]
process_name=%(program_name)s_%(process_num)02d
command=/root/go/bin/supercronic /root/supercronic/adcs.cron
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/adcs/storage/logs/adcs-cron.log
stdout_logfile_maxbytes=0
stopwaitsecs=3600

[program:adcs-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/adcs/artisan queue:work database --sleep=3 --tries=3
autostart=true
autorestart=true
user=root
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/adcs/storage/logs/adcs-worker.log
stdout_logfile_maxbytes=0
stopwaitsecs=3600

[program:adcs-octane]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/adcs/artisan octane:start --max-requests=500
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/adcs/storage/logs/adcs-octane.log
stdout_logfile_maxbytes=0
stopwaitsecs=3600
```

> Sesuaikan `/var/www/adcs` dengan lokasi direktori proyek

- `sudo supervisorctl reread`
- `sudo supervisorctl update`
- `sudo supervisorctl restart all`

> #### πŸ“ Informasi
> - Pastikan ekstensi PHP yang dibutuhkan Laravel `v8` sudah terpasang pada server, sesuai dokumentasi [berikut](https://laravel.com/docs/8.x/deployment)

> #### πŸ’‘ Opsional
> - Untuk mempercepat performa aplikasi, jalankan `php artisan optimize` saat setelah update source code pada aplikasi

> #### πŸ‘Œ Rekomendasi
> - Gunakan OS berbasis Linux (e.g. Ubuntu 20.04.3 LTS)

> - Gunakan Web Server [Nginx](https://nginx.org/en/download.html), [Apache2](https://httpd.apache.org/download.cgi), atau [LiteSpeed](https://openlitespeed.org/Downloads/)