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
| What | Where |
|---|---|
| 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 log | server/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.
sudo bash server/restart.shLaravel's own commands run through the same folder, for example:
sudo bash server/artisan.sh schedule:listWhat runs
| Service | What it does |
|---|---|
saas-web | The web app |
php8.5-fpm | The API and the AI's chat replies |
saas-queue@1saas-queue@2 | Knowledge files, emails, reminders, call logs, data exports and Stripe payments |
saas-scheduler | Renewals, billing checks, reminders and clean-ups |
saas-reverb | Live updates in the panels |
saas-voice | The phone agent |
systemctl status 'saas-*' # is everything running?
sudo journalctl -u saas-web -n 50 # the last 50 lines of one serviceLogs
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.
| What | Where | Why |
|---|---|---|
| The database | PostgreSQL, saas | Every account, message, appointment and payment |
| Uploads | backend/storage/app | Knowledge files, avatars, exports, call recordings |
| Settings | backend/.envfrontend/.env.local | Without APP_KEY, the stored keys and tokens cannot be read again |
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.localServer size
| Use | CPU | Memory | Disk |
|---|---|---|---|
| Trying it out, or a demo | 2 cores | 4 GB | 40 GB SSD |
| Up to about 50 active businesses | 4 cores | 8 GB | 80 GB SSD |
| More | Move PostgreSQL to a server of its own, then allow more replies (below) and add queue workers | 8 GB or more each | Grows 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:
sudo grep max_children /var/log/php8.5-fpm.logRaise 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:
sudo systemctl reload php8.5-fpmBehind 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:
IMAGE_REMOTE_HOSTS=cdn.example.com,*.s3.amazonaws.comSign-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_HOURSinbackend/.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.
| When | What it does |
|---|---|
| Every hour | Tries again the Stripe events whose handling failed, since Stripe stops retrying after three days |
| Every hour | Moves free plans into their next month, so their AI keeps answering |
| Every hour | Registers the WhatsApp and Messenger reminder templates with Meta, and picks up Meta's review result |
| Daily, 00:00 | Deletes expired data exports |
| Daily, 00:01 | Expires subscriptions past their end date |
| Daily, 00:05 | Removes expired discounts |
| Daily, 00:10 | Starts the monthly allowance again for plans billed quarterly or yearly |
| Daily, 03:00 | Deletes messages older than the retention period (30 days, until you change it in Settings → Privacy) |
| Daily, 03:30 | Renews WhatsApp tokens that expire within 14 days |
| Daily, 03:30 | Compares every running subscription with Stripe and corrects any difference |
| Daily, 09:00 | Reminds businesses that pay by bank transfer to pay before their plan ends |
| Monthly, the 1st, 00:30 | Expires idle referral points, when that is switched on in Referral Program → Settings |
| Sunday, 02:00 | Audits conversations for messages from minors |
| Daily, 04:00 | On a live demo only: loads the demo data again |