Deploy a new version
A running nvs serve uses new code and most configuration changes without a restart. This page shows a
deploy that is safe at every step. The last section shows how to work the same way while you
develop, alone or with a coding agent.
Put the release in place
Section titled “Put the release in place”Copy each release into a folder of its own. A link named current points to the release that
runs:
/srv/shop/ releases/ 2026-11-20/ 2026-11-21/ current -> releases/2026-11-21Start the server with the path through the link:
nvs serve /srv/shop/current/public/index.nvsCopy the new release into its own folder first. When the copy is complete, switch the link. On Linux, these two commands replace the link in one step:
ln -sfn releases/2026-11-21 /srv/shop/current.newmv -T /srv/shop/current.new /srv/shop/currentThe server reads the link at the start of each compile and again at the end. If the link changed during the compile, the server throws that compile away and compiles again. So it never builds one program from two releases.
Make the server use it now
Section titled “Make the server use it now”The server finds the change by itself within [opcache] revalidate_freq. The default is 2s. Run
nvs reload to make the change take effect at once, and to see the result:
nvs reloadserver 4120: configuration unchanged, 1 program reloaded, 0 programs with errorsThe server checks its configuration files and every program it has loaded. The command returns when every compile has ended. A program that no request has loaded yet is compiled by its first request.
A reload compiles only the functions that changed. The server uses its saved code for every other
function. The log has one program reloaded line for each program. Its compiled field is the
number of functions compiled, and reused is the number used again.
Run nvs reload as the account that runs the server, or as an administrator. It reloads every
server that uses the same data folder. The data folder is where nvs keeps its own files,
such as the compile cache. If the server was started with --data, give the same
--data to nvs reload. --json prints the result as one JSON document.
Check the exit code
Section titled “Check the exit code”| Exit code | Meaning |
|---|---|
0 |
Every server uses the files on disk. |
1 |
A configuration file or a program has an error. Each error is printed with its file and line. A server that did not reply also gives 1. |
2 |
No server is running for this data folder. |
When a program has an error, the server does not use the new version of it. Every request to that
program fails with the error until you fix the file.
When a server does not reply, the command cannot tell which files it uses. Its line says
could not be reached or closed the connection without a reply.
So a deploy script switches back to the previous release when the exit code is 1:
#!/bin/shcd /srv/shopln -sfn releases/2026-11-21 current.newmv -T current.new current
nvs reloadcase $? in 0) echo "The new release is live." ;; 1) echo "The reload failed. Switching back." ln -sfn releases/2026-11-20 current.new mv -T current.new current nvs reload exit 1 ;; 2) echo "No server is running. The server uses the new release when it starts." ;;esacDatabase changes
Section titled “Database changes”Run a database change with nvs run, before you switch the link. nvs run starts a new process
and compiles the program from the disk, so it needs no reload:
nvs run /srv/shop/releases/2026-11-21/bin/migrate.nvsRequests that started before the switch finish on the old code. So for a short time, both versions run. Write each database change so that the old code still works with it. The new code must also read what the old code wrote, such as sessions, cache entries and queued jobs.
Good to know
Section titled “Good to know”- A configuration file is read again on every reload, also through a link. A key that needs a
restart, such as
[server] listen, is written to the log and takes effect at the next start. - Static files still come from the release that the server started with.
- A
[[server.mount]]table reads the links of its mounts when the server starts. With a mount table, a switched link takes effect at the next start.
While you develop, and with a coding agent
Section titled “While you develop, and with a coding agent”The server compiles a changed program when its files stay unchanged for [opcache] settle. A
person or a coding agent can pause between two edits for longer than that. The server then
compiles a program that is only half edited, and logs errors that you did not make.
To stop this, set a long revalidate_freq, so that the server checks its files only once an hour.
Then run nvs reload after each batch of edits:
[opcache]revalidate_freq = "1h"nvs reload prints each error with its file and line, so you or the agent can fix it at once. A
reload that you forget still takes effect within one hour. nvs agent primer tells a coding agent
to run nvs reload after its edits.
In development, the server also keeps the result of checking each file for errors in memory. A reload after an
edit inside one function then checks one file and compiles one function, at any program size. The
setting is [opcache] incremental. Its default is true in development and false in production,
where the server frees this memory after each compile:
[opcache]incremental = trueRead every option in Reference: nvs reload.
