Lesson 2.2: Keeping Velocity running
A long-running server must come back after a reboot and after a crash, and an operator must be able to reload it
without dropping requests. This lesson covers the control verbs, a boot unit, the optional watchdog, the logs and the
configuration tree that is laid out like Debian's /etc/apache2.
At a glance
| Course | Hosting and operations |
| Module | Module 2: Velocity |
| Duration | 45 minutes (20 presenting, 25 exercise) |
| Level | Intermediate |
| Audience | System administrators and hosting support staff |
| Prerequisites | Lesson 2.1; root on the learner's own virtual machine for the boot unit |
Learning objectives
After this lesson, learners can:
- choose between
stop,restart,gracefulandkillfor a situation; - write a systemd unit that runs
exp:velocity start,stopandgraceful; - explain when the watchdog starts the server and when it does not;
- find the access log, the error log,
console.logand the pid file; - read the configuration tree with
exp:velocity layout.
Trainer's notes
How to present it
Source: Velocity for hosts and Chapter 8, sections 8.3.10 to 8.3.12.
- The verbs (4 minutes).
stopasks the server to stop and waits;restartstops and starts and succeeds only when a new parent answers;gracefulre-executes the server while keeping the listening socket, so no request is dropped;killstops without asking, for a wedged worker. A stopped server stays stopped: the watchdog does not start it again untilstart. - Boot service (5 minutes).
exp:velocityhas no command that installs one. The engine's own units start the engine directly and bypass whatexp:velocityadds (the generated site file,KeepGlobals, PHP options, the worker user). Show the derived unit of section 8.3.11:Type=forking,ExecStartwithexp:velocity start,ExecReloadwithgraceful,PIDFileonvar/vc/qbix/run/server.pid. It is not shipped. - The watchdog (4 minutes). Off until installed (root, systemd). It starts the engine only when no process of it
runs, nobody stopped it on purpose, no restart is in progress and it is not backing off. It never stops or restarts
a running server. Log:
var/log/velocity-watchdog.log. - Logs (3 minutes).
var/vc/qbix/log/<siteaccess>-access.logand-error.log;var/vc/qbix/run/console.logfor start-up lines; the kernel's own logs stay invar/<site>/log/. - The tree (4 minutes).
/etc/vcwhen run as root, elsevar/vc/qbix/etc.vc.conf,ports.conf,envvars,conf-,mods-andsites-availablewith-enabledsymlinks, enabled withexp:velocity site|conf|mod enable.
Common questions
Which verb after a PHP change? None of these alone: exp:velocity deploy (Module 4) runs the steps in order.
Does graceful work on every engine? It is a verb for every engine; on FrankenPHP it reloads the configuration
through Caddy's admin API.
Can I edit a generated file in the tree? Generated files carry "_generated": "exp:velocity"; remove the marker
and the file is never overwritten again, like a dpkg conffile.
Who may read the access log? It names visitors, so [LogSettings] FileMode ships as 0640.
Pitfalls
- Two units for the same ports. Do not combine the derived unit with the operating-system package's unit.
Instancesabove 1. ThePIDFilethen names instance 0 only.- Learners without root. Without root, the tree is in
var/vc/qbix/etcand the boot unit cannot be installed; let them write the unit file and read it with the trainer. - Stopping the trainer's demo server. Each learner controls only their own installation.
Hands-on exercise
Use your own training installation from lesson 2.1, served by Velocity.
- Run
php bin/php/console exp:velocity graceful, thenstatus. Note that the site kept answering. - Run
php bin/php/console exp:velocity restartand check withstatusthat a new parent answers. - List the log directory:
ls -l var/vc/qbix/log/. Note the access and error log names and their mode. - Read the last access lines:
tail -n 5 var/vc/qbix/log/*-access.log. - Show the configuration tree:
php bin/php/console exp:velocity layout. Note which directory is used and which modules are enabled. - Print the command line the server would run:
php bin/php/console exp:velocity command. - On a virtual machine where you are root, write the derived unit of
section 8.3.11 to
/etc/systemd/system/exponential-velocity-training.service, with your installation path. - Stop the server you started by hand (
exp:velocity stop), then runsystemctl daemon-reloadandsystemctl enable --now exponential-velocity-training. - Check with
systemctl status exponential-velocity-trainingandexp:velocity status. - Read the watchdog's state without installing it:
php bin/php/console exp:velocity watchdog status.
Expected result
- Steps 1 and 2: the site answers after each command;
statusshows a new parent afterrestart. - Step 3: the logs exist with mode
-rw-r-----(0640). - Step 5 names
/etc/vc(as root) orvar/vc/qbix/etc. - Step 9: systemd shows the unit active and
exp:velocity statusshows the server running. - Step 10 reports that the watchdog is not installed (it is off until installed).
- The trainer checks one learner's
systemctl statuson the projector.
Quiz
- Which verb reloads Velocity without dropping a request?
A.
restartB.killC.gracefulD.stop - Why does the derived unit run
exp:velocity startrather than the engine directly? - You stopped Velocity on purpose with
exp:velocity stop. Will the watchdog start it again? - Where are the start-up lines, such as
Workers as: ..., written? - What does
exp:velocity conf enable <name>do?
Answers
- C. It re-executes the server while keeping the listening socket.
- Starting the engine directly bypasses what
exp:velocityadds: the generated site file,KeepGlobals, the PHP options, the worker user, the engine archive and the instances (section 8.3.11). - No. It does not start a server that was stopped on purpose, until
start. - In
var/vc/qbix/run/console.log. - It links
conf-available/<name>.confintoconf-enabled/, asa2enconfdoes.
Further reading
- Velocity for hosts: boot service, watchdog and logs.
- Velocity will not start: what to do when it does not come up.
- Velocity control panel and dashboard: the
/Q/pages. - Velocity scheduler: tasks the server runs on a schedule.
Related pages
- Module 2: Velocity
- Hosting and operations: course overview
- Trainers: start here
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.