Ninshiki Backend Documentation Help

Installation for Production

Pre-requisite

PHP Extension

  • PHP >= 8.2

  • Ctype PHP Extension

  • cURL PHP Extension

  • DOM PHP Extension

  • Fileinfo PHP Extension

  • Filter PHP Extension

  • Hash PHP Extension

  • Mbstring PHP Extension

  • OpenSSL PHP Extension

  • PCRE PHP Extension

  • PDO PHP Extension

  • Session PHP Extension

  • Tokenizer PHP Extension

  • XML PHP Extension

  • Intl PHP Extension

Email Notification

Create an account in RESEND for email services.

CDN

Create an account in Cloudinary for Image CDN.

Installation

  1. Clone the repository

git clone git@github.com:MarJose123/Ninshiki-backend.git
  1. Copy the .env.example to .env

  2. Update the Laravel Reverb Key by providing a unique key and App Key.

php artisan reverb:key
  1. Update your Cloudinary CLOUDINARY_URL and RESEND_KEY.

  2. Install dependencies

composer install
  1. Generate App Key

php artisan generate:key
  1. Run Database Migration and Seeder

php artisan migrate
  1. Create a user with a permission of an Owner/Administrator

php artisan make:ninshiki-user
  1. Generate Reverb Key

php artisan reverb:key
  1. Now your backend is ready for integration with your frontend.

Supervisor

To install Supervisor on Ubuntu, you may use the following command: sudo apt-get install supervisor.

Supervisor configuration files are typically stored in the /etc/supervisor/conf.d directory. Within this directory, you may create any number of configuration files that instruct supervisor how your processes should be monitored.

Starting Supervisor

Once the configuration file has been created, you may update the Supervisor configuration and start the processes using the following commands:

sudo supervisorctl reread sudo supervisorctl update sudo supervisorctl start "ninshiki-worker-*"

Queues

Let's create a ninshiki-worker-queue.conf file that starts and monitors queue:work processes:

[program:ninshiki-worker-queue] process_name=%(program_name)s_%(process_num)02d command=php /www/backend-ninshiki.com/artisan queue:work --sleep=3 --tries=3 --max-time=3600 autostart=true autorestart=true stopasgroup=true killasgroup=true user=www-data numprocs=8 redirect_stderr=true stdout_logfile=/home/ninshiki/worker-queue.log stopwaitsecs=3600

Pulse Check

Let's create a ninshiki-worker-pulse.conf file that starts and monitors pulse:check processes:

[program:ninshiki-worker-pulse] process_name=%(program_name)s_%(process_num)02d command=php /www/backend-ninshiki.com/artisan pulse:check autostart=true autorestart=true stopasgroup=true killasgroup=true user=www-data numprocs=1 redirect_stderr=true stdout_logfile=/home/ninshiki/worker-pulse.log

Cron Job

In this step, we'll set up a cron job command on the server. If you're using Ubuntu Server, crontab is likely already installed. Run the command below to add a new entry for the cron job.

crontab -e

Task Scheduler (run every 5 minutes)

Copy this cron script to add a new entry for the cron job. Don't forget to update its path of your app.

*/5 * * * * php /www/backend-ninshiki.com/artisan schedule:run >/dev/null 2>&1
Last modified: 15 January 2025