cli.rst 5.9 KB

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