.. include:: /Includes.rst.txt .. _installation-operations: ========== 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: .. code-block:: bash bin/console doctrine:migrations:migrate --no-interaction Cache ===== After installing a package or updating, rebuild the cache in two steps. Without the second, the first requests take several seconds each: .. code-block:: bash bin/console cache:clear --no-warmup bin/console cache:warmup Messenger worker ================ The worker processes background and recurring jobs: .. code-block:: bash bin/console messenger:consume scheduler_default async_high async_low - ``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``: .. code-block:: bash bin/console messenger:failed:show bin/console messenger:failed:retry bin/console messenger:failed:remove 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: .. code-block:: ini [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 Mercure hub =========== Both keys of the hub equal ``MERCURE_JWT_SECRET``: .. code-block:: bash 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 The reverse proxy forwards ``/.well-known/mercure`` to the hub without buffering: .. code-block:: nginx 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; } In ``.env.local``: .. code-block:: bash MERCURE_URL=http://mercure/.well-known/mercure MERCURE_PUBLIC_URL=https://adsum.company.com/.well-known/mercure MERCURE_JWT_SECRET= Mail delivery ============= Set ``MAILER_DSN`` (see :ref:`installation-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 :confval:`env-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: .. code-block:: bash bin/console adsum:files:adopt-legacy --dry-run # list the files that would move bin/console adsum:files:adopt-legacy 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 :confval:`env-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: .. code-block:: sql REVOKE UPDATE, DELETE ON audit_entry FROM adsum_app; GRANT SELECT, DELETE ON audit_entry TO adsum_purge; MariaDB, with table-level grants instead of a database-wide ``UPDATE`` and ``DELETE``: .. code-block:: sql GRANT SELECT, INSERT ON adsum.audit_entry TO 'adsum_app'@'%'; GRANT SELECT, DELETE ON adsum.audit_entry TO 'adsum_purge'@'%'; 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 :ref:`installation-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: .. code-block:: bash bin/console app:branding:login-company # show the login company bin/console app:branding:login-company --company= bin/console app:branding:login-company --clear Logs ==== Check ``var/log/prod.log`` after a deploy and when users report errors (see :ref:`installation-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: .. code-block:: bash bin/console app:attendance:import-punches punches.csv 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: .. code-block:: bash bin/console adsum:attendance:mute-violation-notices on bin/console adsum:attendance:mute-violation-notices off 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: .. code-block:: bash bin/console adsum:helpdesk:import-starter-faqs bin/console adsum:helpdesk:import-starter-faqs --entry=requestLeave --entry=raiseTicket Entries whose English question the company has already are skipped, so the command can run again.