platformservice
v41.16.0
Published
A simple platform allowing folks to connect w. their communities.
Downloads
11
Readme
PlatformService
PlatformService is a Lumen app that facilitates a bunch of features for our service Letterhead. It is largely responsible for the management of newsletters, and acts as an API gateway for additional services that handle roles, permissions, users, link resolution, pixel tracking, and so on.
Installation
Using Docker and docker-compose
Let's assume that the user already have docker installed, if not please refer to: https://docs.docker.com/engine/ and https://docs.docker.com/compose/
- Navigate to the project root direcotry.
- Be sure you have a .env file already configured.
- Change the DB_HOST variable into the .env as shown:
DB_HOST=db-platformservice
- Add the following the the .env file:
NGINX_HOST=<host_name_you_want>
Examle: NGINX_HOST=platformservice.com
- Add the <host_name_you_want> to the host file on your OS.
- Run the following command:
* docker-compose build dev
* docker-compose up -d
* docker-compose exec app composer install
* docker-compose exec php artisan migrate
That's it! Now visit <host_name_you_want>:8080 Ex: http://platformservice.com:8080
If you want to browse the database, connect to: Host: 127.0.0.1 Port: 3305 Username: The user configured on .env Password: The pass configured on .env
Deploy
DigitalOcean
We can deploy PlatformService on DigitalOcean's App Platform. A template "app spec"
lives in the .do/
directory. Treat it like a .env.example
. It's a little more verbose,
but the principle is the same. Rename the service, and swap {VALUE}
with the appropriate values in a file named how
you like. You can then deploy it using DigitalOcean's doctl
CLI with
doctl apps create --spec path/to/spec
If you have doctl
installed, your YAML is valid, and you have the appropriate privileges,
this will deploy PlatformService to the app platform at a new url, which you can retrieve
from doctl
or through the browser by logging into DigitalOcean.
On an Ubuntu server
Scheduled tasks and queues
PlatformService relies on a variety of scheduled tasks (or cron jobs) and queues to perform functions behind the scenes. You'll need to be familiar with Lumen and Laravel. The documentation on Queues, Jobs, Tasks, and the like, is really quite good.
Supervisor
In a live environment you'll find that we rely on Supervisor, which runs in the background
on an Ubuntu server and manages processes (like queues!) for us. You can find PlatformService's
Supervisor configuration file at the root of this repo :) called lumen-queue-platformservice.conf
.
- Place this in
/etc/supervisor/conf.d/
supervisorctl reread
supervisorctl update
supervisorcl restart all
Cron
Our tasks and recurring jobs are found in app/console/Kernel.php
. In a live environment, to have the server
run these you will need to edit your cron sudo crontab -e
and add
* * * * * cd /path/to/platformservice && php artisan schedule:run >> /dev/null 2>&1
Small test