- create database
acumer - enable consumer by calling the api
https://reporter.yourdomain.com/v1/events/location/registerand pass the body as followings:
{
// "producer_info": {
// "info":{
// "local_spawn": true,
// "notif_data": {
// "receiver_info": { "id": 1 },
// "id": "unqie-id",
// "action_data": {
// "pid": 200
// },
// "actioner_info": { "id": 2 },
// "action_type": "ProductPurchased",
// "fired_at": 1714316645,
// "is_seen": false
// },
// "exchange_name": "wildonionExchange",
// "exchange_type": "fanout", // amq.topic for pubsub
// "routing_key": "" // routing pattern or key - will be ignored if type is fanout
// }
// },
"producer_info": null,
// "consumer_info": null
"consumer_info": {
"info": {
"queue": "RustReporterQ",
"exchange_name": "Events:LocationEvent",
"routing_key": "",
"tag": "cons_tag0",
"redis_cache_exp": 300,
"local_spawn": true
}
}
}
- get basic report:
https://reporter.yourdomain.com/v1/events/location/stats/get/basic/?imei=&from=&to=
if you want to deploy as a publisher or producer service then get your hands dirty by developing the
apis/http,actors/producers, as a subscriber or consumer however, develop theapis/http,actors/consumersfolders.
make sure you've created the database using:
sqlx database createmake sure you uncomment the runtime setup inside its
Cargo.tomlfile.
sea-orm-cli migrate init -d migrationmake sure you've installed the
sea-orm-clithen create migration file per each table operation, containsMigrationsstructure withupanddownmethods extended by theMigrationTraitinterface, take not that you must create separate migration per each db operation when you're in production.
sea-orm-cli migrate generate "table_name"once you've done with adding changes in your migration files just run the following to apply them in db.
# rollback all applied migrations, then reapply all migrations
sea-orm-cli migrate refresh # or upgenerate Rust structures from your applied migrations inside the db for the
acumerdatabase inentity/srcfolder after that you can proceed with editing each eintity like adding hooks for different actions on an active model.
# generate entities for the database and all tables
sea-orm-cli generate entity -u postgres://postgres:geDteDd0Ltg2135FJYQ6rjNYHYkGQa70@localhost/acumer -o src/entities --with-serde both --serde-skip-deserializing-primary-key
# generate entity for an sepecific table only, eg: generating entity for hoops table
sea-orm-cli generate entity -t hoops -o src/entities --with-serde both --serde-skip-deserializing-primary-key
# don't skip deserializing primary key
sea-orm-cli generate entity -u postgres://postgres:geDteDd0Ltg2135FJYQ6rjNYHYkGQa70@localhost/acumer -o src/entities --with-serde bothwhen you run server with
--freshcommand it'll fresh all migrations at startup (drop all tables from the database, then reapply all migrations) otherwise it'll only apply migrations (callingupmethod of all migration files).
# -------------------------------
# ------ acumer server --------
# -------------------------------
# launch as http with freshing db
cargo run --bin acumer -- --server http --fresh # default is http and fresh migrations
# or see help
cargo run --bin acumer -- --helpmake sure you've opened all necesary domains inside your DNS panel per each nginx config file and changed the
your-app.appto your own domain name in every where mostly the nginx config files and theAPP_NAMEinconsts.rs.
# -----------------------
# ---- read/write access
sudo chown -R root:root . && sudo chmod -R 777 . this approach can be used if you need a fully automatic deployment process, it uses github actions to build and publish all images on a self-hosted docker registry on a custom VPS, so update the github ci/cd workflow files inside
.github/workflowsfolder to match your VPS infos eventually on every push the ci/cd process will begin to building and pushing automatically the docker images to the self-hosted registry. instead of using a custom registry you can use either ducker hub or github packages! it's notable that you should renew nginx service everytime you add a new domain or subdomain (do this on adding a new domain),./renew.shscript creates ssl certificates with certbot for your new domain and add it inside theinfra/docker/nginxfolder so nginx docker can copy them into its own container! for every new domain there must be its ssl certs and nginx config file inside that folder so make sure you've setup all your domains before pushing to the repo. continue reading...
-
step1) first thing as the first, connect your device to github for workflow actions using
gh auth login -s workflow. -
step2) run
sudo rm .env && sudo mv .env.prod .envthen update necessary variables inside.envfile. -
step3) the docker registry service is up and running on your VPS.
-
step4) you would probably want to make
logsdir anddocker.yourdomain.comroutes secure and safe, you can achive this by adding an auth gaurd on the docker registry subdomain and the logs dir inside their nginx config file eventually setup the password forlogsdir anddocker.yourdomain.comroute by runningsudo apt-get install -y apache2-utils && htpasswd -c infra/docker/nginx/.htpasswd acumercommand, the current one isacumer@1234. -
step5) setup
DOCKER_PASSWORD,DOCKER_USERNAME,SERVER_HOST,SERVER_USERandSERVER_PASSWORDsecrets and variables on your repository. -
step6) setup nginx config and ssl cert files per each domain and subdomain using
renew.shscript then put them insideinfra/docker/nginxfolder, you MUST do this before you get pushed to the repo on github cause there is already an nginx container inside thedocker-compose.yml. -
step7) created a
/root/hoopoefolder on your VPS containing thedocker-compose.ymlfile only and update its path inside thecicd.ymlfile, take this note that the default location and directory for none root users are/home. -
step8) each image name inside your compose file must be prefixed with your docker hub registry endpoint which in this case is
docker.yourdomain.comcause the doamin is already pointing to the docker registry hosted onlocalhost:5000on VPS.
-
step1) read the codes inside the repository to find the
docker-compose.ymlfile. -
step1) try to login (docker username and password) to your custom docker hub (the registry on your VPS secured with nginx auth gaurd).
-
step2) build all docker container images inside your
docker-compose.ymlfile. -
step3) eventually it push them to your custom docker hub registry.
-
step4) ssh to the VPS and cd to where you've put the
docker-compose.ymlfile in there then pull and up all pushed docker containers from the VPS hub inside the VPS.