From the kitten command to the CLI
Flowchart from the Technical Manual.
Text version
- kitten [command] [arguments]
- ~/.local/bin/kitten links to app/kitten, which resolves to versions/exact version/kitten
- Save the working directory and change to the version folder
- runtimes/node-version/bin/node exists?
- Exit with error
- Unset PRODUCTION unless it is exactly true
- PRODUCTION=true and updates/pending exists?
- update-guard.js start
- exec app/kitten (the version the guard switched to)
- Exit with that code
- PRODUCTION, FLAME_GRAPH, or INSPECT is true?
- node --enable-source-maps --import ./loader-bundle.js kitten-bundle.js (the launcher waits)
- main.ts: kitten global, kitten.log, data migration, kitten.__db
- exits with 99 or another error, in the systemd service: systemd restarts kitten.service (Restart=on-failure)
- First argument in the launcher’s command list?
- Yes: run, db, _db, deploy, status, logs, start, stop, restart, enable, disable, update, uninstall, version, help, --version, or --help: node --enable-source-maps --import ./loader-bundle.js kitten-bundle.js (the launcher waits)
- No: serve, a path, init, add, check, shell, -v, -h, or no argument: exec node --enable-source-maps --import ./loader-bundle.js kitten-process-manager.js
- exec node --enable-source-maps --import ./loader-bundle.js kitten-process-manager.js
- cluster.fork(): the worker imports kitten-bundle.js
- main.ts: kitten global, kitten.log, data migration, kitten.__db
- worker exits with 99: app points to a different version?
- any other exit code: The process manager exits with that code
- main.ts: kitten global, kitten.log, data migration, kitten.__db
- CLI parses the arguments and runs the command
- app points to a different version?
- process.execve(app/kitten) in the original working directory
- The process manager exits with that code
- systemd restarts kitten.service (Restart=on-failure)