Demo mode: changes are disabled.

Skip to content

Server Care

Last updated

Look after the server that runs Deskply: where everything is, restarts, logs, backups, more capacity, proxies and scheduled tasks.

Where everything is

WhatWhere
Settings of the API/var/www/saas/backend/.env
Settings of the web app/var/www/saas/frontend/.env.local
Your answers to the setup, and its logserver/setup.conf and server/setup.log
nginx/etc/nginx/conf.d/saas-*.conf
PHP-FPM/etc/php/8.5/fpm/pool.d/saas-api.conf
Services, with their ports and the Node.js they use/etc/systemd/system/saas-*.service
HTTPS certificate/etc/letsencrypt/live/saas/, renewed by itself

The setup replaces the nginx, PHP-FPM and service files when you run it again or update. To keep your own version of one, remove its first line.

After a change

After you edit .env, .env.local or the source, run this in /var/www/saas. It refreshes the caches, builds the web app again when it has to, and restarts everything. Changes made in the admin panel do not need it.

Terminal
sudo bash server/restart.sh

Laravel's own commands run through the same folder, for example:

Terminal
sudo bash server/artisan.sh schedule:list

What runs

ServiceWhat it does
saas-webThe web app
php8.5-fpmThe API and the AI's chat replies
saas-queue@1saas-queue@2Knowledge files, emails, reminders, call logs, data exports and Stripe payments
saas-schedulerRenewals, billing checks, reminders and clean-ups
saas-reverbLive updates in the panels
saas-voiceThe phone agent
Terminal
systemctl status 'saas-*'          # is everything running?
sudo journalctl -u saas-web -n 50   # the last 50 lines of one service

Logs

The API writes one laravel-YYYY-MM-DD.log a day in backend/storage/logs/ and deletes those older than 14 days. LOG_LEVEL, LOG_DAILY_DAYS and LOG_STACK in .env change that. nginx writes to /var/log/nginx/.

Backups

Back up three things every day, and keep the copies away from the server.

WhatWhereWhy
The databasePostgreSQL, saasEvery account, message, appointment and payment
Uploadsbackend/storage/appKnowledge files, avatars, exports, call recordings
Settingsbackend/.envfrontend/.env.localWithout APP_KEY, the stored keys and tokens cannot be read again
Terminal
sudo -u postgres pg_dump saas | gzip > saas-$(date +%F).sql.gz
sudo tar -czf saas-files-$(date +%F).tar.gz -C /var/www/saas \
  backend/storage/app backend/.env frontend/.env.local

Server size

UseCPUMemoryDisk
Trying it out, or a demo2 cores4 GB40 GB SSD
Up to about 50 active businesses4 cores8 GB80 GB SSD
MoreMove PostgreSQL to a server of its own, then allow more replies (below) and add queue workers8 GB or more eachGrows with uploads and messages

These are a starting point: watch the memory and the CPU. The AI does not run on your server, so it needs no GPU. For a third queue worker, run sudo systemctl enable --now saas-queue@3.

More replies at the same time

PHP-FPM writes each chat reply inside the request that brings the message, and waits for the AI provider meanwhile. Each reply keeps one process busy, and the panels use the same processes. The setup allows as many as half of the memory holds (10 to 60). When this prints server reached pm.max_children setting, the limit is too low:

Terminal
sudo grep max_children /var/log/php8.5-fpm.log

Raise pm.max_children in /etc/php/8.5/fpm/pool.d/saas-api.conf (about 80 MB of memory each), remove the first line of the file so that your number stays, and reload:

Terminal
sudo systemctl reload php8.5-fpm

Behind a proxy

Rate limits and the sign-in logs use the visitor's IP address. Behind Cloudflare, another CDN or a load balancer, list its addresses in TRUSTED_PROXIES in backend/.env, comma-separated; otherwise every visitor shares the address of the proxy. Do not use *: it lets anyone choose the address that is recorded. Pages are made for each visitor, so do not cache their HTML at a CDN.

Uploads on S3

To store uploads in an S3 bucket, set FILESYSTEM_DISK and the AWS_* settings in backend/.env. The web app loads images only from the API, so add the host of the bucket, or of any other place images come from, to frontend/.env.local:

frontend/.env.local
IMAGE_REMOTE_HOSTS=cdn.example.com,*.s3.amazonaws.com

Sign-in protection

  • Five wrong passwords for one email from one IP address block that pair for 15 minutes. For an admin, twenty from any address block the account for 60 minutes.
  • Five wrong codes void an email verification or a password reset; the visitor asks for a new code.
  • “Forgot password” never reveals whether an account exists, and a reset signs out every session of that account.
  • An admin sign-in lasts 12 hours (ADMIN_TOKEN_TTL_HOURS in backend/.env).
  • There is no two-factor authentication app: new accounts and password resets use a code by email.

Scheduled tasks

These run by themselves. The times are in UTC.

WhenWhat it does
Every hourTries again the Stripe events whose handling failed, since Stripe stops retrying after three days
Every hourMoves free plans into their next month, so their AI keeps answering
Every hourRegisters the WhatsApp and Messenger reminder templates with Meta, and picks up Meta's review result
Daily, 00:00Deletes expired data exports
Daily, 00:01Expires subscriptions past their end date
Daily, 00:05Removes expired discounts
Daily, 00:10Starts the monthly allowance again for plans billed quarterly or yearly
Daily, 03:00Deletes messages older than the retention period (30 days, until you change it in Settings → Privacy)
Daily, 03:30Renews WhatsApp tokens that expire within 14 days
Daily, 03:30Compares every running subscription with Stripe and corrects any difference
Daily, 09:00Reminds businesses that pay by bank transfer to pay before their plan ends
Monthly, the 1st, 00:30Expires idle referral points, when that is switched on in Referral Program → Settings
Sunday, 02:00Audits conversations for messages from minors
Daily, 04:00On a live demo only: loads the demo data again