cli.rst 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. Command Line Reference
  2. ======================
  3. Lakesuperior comes with some command-line tools aimed at several purposes.
  4. If Lakesuperior is installed via ``pip``, all tools can be invoked as normal
  5. commands (i.e. they are in the virtualenv ``PATH``).
  6. The tools are currently not directly available on Docker instances (*TODO add
  7. instructions and/or code changes to access them*).
  8. ``lsup-server``
  9. ---------------
  10. Single-threaded server. Use this for testing, debugging, or to multiplex via
  11. WSGI in a Windows environment. For non-Windows production environments, use
  12. ``fcrepo``.
  13. ``fcrepo``
  14. ----------
  15. This is the main server command. It has no parameters. The command spawns
  16. Gunicorn workers (as many as set up in the configuration) and can be sent in
  17. the background, or started via init script.
  18. The tool must be run in the same virtual environment Lakesuperior
  19. was installed in (if it was)—i.e.::
  20. source <virtualenv root>/bin/activate
  21. must be run before running the server.
  22. Note that if ``app_mode`` is set to ``prod`` in :doc:`application.yml
  23. <config>`, the server will just print the configuration and immediately go in
  24. the background without logging anything on screen (daemon mode).
  25. In the case an init script is used, ``coilmq`` (belonging to a 3rd party
  26. package) needs to be launched as well; unless a message broker is already set
  27. up, or if messaging is disabled in the configuration.
  28. **Note:** This command is not available in Windows because GUnicorn is not
  29. available in Windows. Windows users should look for alternative WSGI servers
  30. to run the single-threaded service (``lsup-server``) over multiple processes
  31. and/or threads.
  32. ``lsup-admin``
  33. --------------
  34. ``lsup-admin`` is the principal repository management tool. It is
  35. self-documented, so this is just a redundant overview::
  36. $ lsup-admin
  37. Usage: lsup-admin [OPTIONS] COMMAND [ARGS]...
  38. Options:
  39. --help Show this message and exit.
  40. Commands:
  41. bootstrap Bootstrap binary and graph stores.
  42. check_fixity [STUB] Check fixity of a resource.
  43. check_refint Check referential integrity.
  44. cleanup [STUB] Clean up orphan database items.
  45. migrate Migrate an LDP repository to Lakesuperior.
  46. stats Print repository statistics.
  47. All entries marked ``[STUB]`` are not yet implemented, however the
  48. ``lsup_admin <command> --help`` command will issue a description of what
  49. the command is meant to do. Check the
  50. `issues page <https://github.com/scossu/lakesuperior/issues>`__ for what's on
  51. the radar.
  52. All of the above commands are also available via, and based upon, the
  53. native Python API.
  54. ``lsup-benchmark``
  55. ------------------
  56. This command is used to run performance tests in a predictable way.
  57. The command line options can be queried with the ``--help`` option::
  58. Usage: lsup-benchmark [OPTIONS]
  59. Run the benchmark.
  60. Options:
  61. -m, --mode TEXT Mode of ingestion. One of `ldp`, `python`. With
  62. the former, the HTTP/LDP web server is used. With
  63. the latter, the Python API is used, in which case
  64. the server need not be running. Default:
  65. http://localhost:8000/ldp
  66. -e, --endpoint TEXT LDP endpoint. Only meaningful with `ldp` mode.
  67. Default: http://localhost:8000/ldp
  68. -c, --count INTEGER Number of resources to ingest. Default: {def_ct}
  69. -p, --parent TEXT Path to the container resource under which the new
  70. resources will be created. It must begin with a
  71. slash (`/`) character. Default: /pomegranate
  72. -d, --delete-container Delete container resource and its children if
  73. already existing. By default, the container is not
  74. deleted and new resources are added to it.
  75. -X, --method TEXT HTTP method to use. Case insensitive. Either PUT
  76. or POST. Default: PUT
  77. -s, --graph-size INTEGER Number of triples in each random graph, rounded
  78. down to a multiple of 8. Default: 200
  79. -S, --image-size INTEGER Size of random square image, in pixels for each
  80. dimension, rounded down to a multiple of 8.
  81. Default: 1024
  82. -t, --resource-type TEXT Type of resources to ingest. One of `r` (only LDP-
  83. RS, i.e. RDF), `n` (only LDP-NR, i.e. binaries),
  84. or `b` (50/50% of both). Default: r
  85. -P, --plot Plot a graph of ingest timings. The graph figure
  86. is displayed on screen with basic manipulation and
  87. save options.
  88. --help Show this message and exit.
  89. The benchmark tool is able to create RDF sources, or non-RDF, or an equal mix
  90. of them, via POST or PUT, in a given lDP endpoint. It runs single threaded.
  91. The RDF sources are randomly generated graphs of consistent size and
  92. complexity. They include a mix of in-repository references, literals, and
  93. external URIs. Each graph has 200 triples by default.
  94. The non-RDF sources are randomly generated 1024x1024 pixel PNG images.
  95. You are warmly encouraged to run the script and share the performance results (
  96. *TODO add template for posting results*).
  97. ``lsup-profiler``
  98. -----------------
  99. This command launches a single-threaded HTTP server (Flask) on port 5000 that
  100. logs profiling information. This is useful for analyzing application
  101. performance.
  102. For more information, consult the `Python profilers guide
  103. <https://docs.python.org/3/library/profile.html>`__.
  104. Do not launch this while a WSGI server (``fcrepo``) is already running, because
  105. that also launches a Flask server on port 5000.
  106. Locust (experimental)
  107. ---------------------
  108. `Locust <http://locust.io>`__ is an HTTP load tester. It can launch many
  109. requests on an HTTP endpoint. A rudimentary Locust file is currently available.
  110. To run Locust against Lakesuperior or FCREPO, run in the project root::
  111. locust -f lakesuperior/util/locustfile.py http://localhost:8000/