Operations 

An installation runs a web server with PHP, a database, a Messenger worker and a Mercure hub.

Database migrations 

After installing a package or updating, run the migrations. The command is safe to repeat:

bin/console doctrine:migrations:migrate --no-interaction
Copied!

Cache 

After installing a package or updating, rebuild the cache in two steps. Without the second, the first requests take several seconds each:

bin/console cache:clear --no-warmup
bin/console cache:warmup
Copied!

Messenger worker 

The worker processes background and recurring jobs:

bin/console messenger:consume scheduler_default async_high async_low
Copied!
  • scheduler_default: recurring jobs such as reminders, daily digests, purges, automatic clock-out and closing attendance days
  • async_high: the consequences of every change, such as recalculations, notifications and live updates
  • async_low: bulk work such as exports, report subscriptions and large recalculations

Without a running worker, changes are saved but their consequences wait in the queues. A missed recurring run is made up once when the worker is back.

Messages that still fail after five retries move to the transport failed:

bin/console messenger:failed:show
bin/console messenger:failed:retry
bin/console messenger:failed:remove <id>
Copied!

Start the worker with the application, restart it when it stops, and on every deploy run bin/console messenger:stop-workers. An example for systemd:

[Unit]
Description=adsum Messenger worker
After=network.target

[Service]
Type=simple
User=www-data
WorkingDirectory=/var/www/adsum
ExecStart=/usr/bin/php bin/console messenger:consume scheduler_default async_high async_low --time-limit=3600
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
Copied!

Mercure hub 

Both keys of the hub equal MERCURE_JWT_SECRET:

docker run -d --name mercure \
  -e SERVER_NAME=':80' \
  -e MERCURE_PUBLISHER_JWT_KEY='the-value-of-MERCURE_JWT_SECRET' \
  -e MERCURE_SUBSCRIBER_JWT_KEY='the-value-of-MERCURE_JWT_SECRET' \
  -e MERCURE_EXTRA_DIRECTIVES=$'anonymous 0\ncors_origins https://adsum.company.com' \
  dunglas/mercure:v0.19
Copied!

The reverse proxy forwards /.well-known/mercure to the hub without buffering:

location /.well-known/mercure {
    proxy_pass http://mercure;
    proxy_http_version 1.1;
    proxy_buffering off;
    proxy_cache off;
    proxy_read_timeout 24h;
    proxy_set_header Connection '';
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
}
Copied!

In .env.local:

MERCURE_URL=http://mercure/.well-known/mercure
MERCURE_PUBLIC_URL=https://adsum.company.com/.well-known/mercure
MERCURE_JWT_SECRET=<the secret>
Copied!

Mail delivery 

Set MAILER_DSN (see Configuration). smtp:// and sendmail:// work out of the box; for a provider such as Amazon SES or Mailgun, install its Symfony Mailer bridge with Composer.

File storage 

Uploaded and generated files lie in the file storage (see ADSUM_FILE_BACKEND). Files that the application kept before it, such as leave attachments, photos, logos and exports, are moved into it once after the update:

bin/console adsum:files:adopt-legacy --dry-run      # list the files that would move
bin/console adsum:files:adopt-legacy
Copied!

The command checks every copy by its checksum and leaves the old files where they are, so it is safe to repeat; files that are gone or changed on the way are listed and stay where they were. Remove the old directories once the list is empty. To move the storage from the server's directory into a bucket, copy var/storage/files into the bucket with the same paths and switch ADSUM_FILE_BACKEND.

Change history protection 

Optionally, protect the change history (table audit_entry) in the database: revoke UPDATE and DELETE from the application's database user and give a second user DELETE for the retention purge. The purge job then runs with the DATABASE_URL of that second user.

PostgreSQL:

REVOKE UPDATE, DELETE ON audit_entry FROM adsum_app;
GRANT SELECT, DELETE ON audit_entry TO adsum_purge;
Copied!

MariaDB, with table-level grants instead of a database-wide UPDATE and DELETE:

GRANT SELECT, INSERT ON adsum.audit_entry TO 'adsum_app'@'%';
GRANT SELECT, DELETE ON adsum.audit_entry TO 'adsum_purge'@'%';
Copied!

Run the migrations with a user that may still change the table.

Backups 

Back up the database, the file storage (var/storage/files or the bucket) and the directories app.photo_directory and app.file_storage_directory (see Composer).

The login company 

The login and password pages show the branding of one company. With one company, that is the one; with several, choose it. Without a choice, the pages show the adsum mark:

bin/console app:branding:login-company                      # show the login company
bin/console app:branding:login-company --company=<company ID>
bin/console app:branding:login-company --clear
Copied!

Logs 

Check var/log/prod.log after a deploy and when users report errors (see Configuration).

Monitoring 

  • Web server and PHP: response times, error rate
  • Database: connections, disk usage
  • Worker: that it runs, and the transport failed
  • Mercure hub: that /.well-known/mercure answers
  • Mail server: delivery failures

Importing punches 

To take over the punches of a previous system:

bin/console app:attendance:import-punches punches.csv
Copied!

The CSV file has the columns employeeId, type (clockIn, clockOut, breakStart, breakEnd) and instant (ISO 8601 with offset), in chronological order. A line that does not fit the punches before it is reported and skipped. Imported punches skip the checks of live punches and notify nobody.

Muting violation notices of one employee 

Stop the notices about working-time violations of one employee:

bin/console adsum:attendance:mute-violation-notices <employee ID> on
bin/console adsum:attendance:mute-violation-notices <employee ID> off
Copied!

The violations are still recorded and shown; the change history records every switch.

Importing the starter FAQ 

Take the starter entries of the help-desk FAQ into a company, in English and German; HR and administrators can do the same on the FAQ page:

bin/console adsum:helpdesk:import-starter-faqs <company ID>
bin/console adsum:helpdesk:import-starter-faqs <company ID> --entry=requestLeave --entry=raiseTicket
Copied!

Entries whose English question the company has already are skipped, so the command can run again.