@@ -13,7 +13,7 @@ userver-create-service [--grpc] [--mongo] [--postgresql] myservice
1313
1414This will create ` myservice ` dir, relative to the current working directory.
1515
16- If the command above is not found, see @ref service_templates .
16+ If the command above is not found, see @ref service_templates_bootstrap .
1717
1818To use additional userver libraries later, see @ref service_templates_libraries.
1919
@@ -27,10 +27,11 @@ If the tests fail and you see messages like "No XXX installation found. Install
2727installed in the environment you are running tests. Do not hesitate to install the missing database servers, like
2828PostgreSQL, MongoDB and others.
2929
30- 4\. To get a feel for how the service runs without needing to set up full production environment, run:
30+ 4\. To get a feel for how the service runs without needing to set up full production environment,
31+ run in the service project root:
3132
3233``` shell
33- myservice$ make start-debug
34+ make start-debug
3435```
3536
3637Wait until the service starts, then try to send a request.
@@ -46,10 +47,10 @@ The answer should be something like this:
4647Hello, userver!
4748```
4849
49- 5\. (Optional) Add the service project to Git:
50+ 5\. (Optional) Add the service project to Git, run in the project root :
5051
5152``` shell
52- myservice$ git init && git add . && git commit -m " Initial commit"
53+ git init && git add . && git commit -m " Initial commit"
5354```
5455
5556Push it to GitHub
@@ -59,39 +60,34 @@ There are preconfigured GitHub CI checks that run ctest tests.
5960
6061Now you are ready for fast and comfortable creation of C++ microservices, services and utilities!
6162
62- ## Quick start for beginners (old way, pre userver 2.8)
63+ @anchor service_templates
64+ ## Service templates for userver based services
6365
64- @warning Service template repositories are deprecated, because possible sets of userver libraries to include cause
65- an exponential growth in the number of wanted repositories. For userver 2.9 and later, use
66- the @ref quick_start_for_beginners "service project generator script" instead.
66+ @anchor service_templates_bootstrap
67+ ### Obtaining the service template scripts
6768
68- 1 \. Press the "Use this template" button at the top right of the appropriate service template repo page:
69+ ` userver-create-service ` is available right away if you have userver @ ref userver_install "installed".
6970
70- | Link | Contains |
71- | ------------------------------------------------------------------| ------------------------|
72- | https://github.com/userver-framework/service_template | HTTP |
73- | https://github.com/userver-framework/pg_service_template | HTTP, PostgreSQL |
74- | https://github.com/userver-framework/pg_grpc_service_template | HTTP, PostgreSQL, gRPC |
75- | https://github.com/userver-framework/mongo_grpc_service_template | HTTP, MongoDB, gRPC |
71+ If you use @ref devcontainers "Dev Containers", or if you @ref userver_cpm "use CPM to download userver",
72+ run this script to get ` userver-create-service ` command:
7673
77- 2\. Clone the service:
74+ * Linux, macOS, BSD: @ref service-template/userver-create-service.sh
75+ * Windows: @ref service-template/userver-create-service.bat
7876
79- ``` shell
80- git clone https://github.com/your-username/your-service.git && cd your-service
81- ```
77+ In the script, replace ` vMAJOR.MINOR ` with the actual userver version, or use ` develop ` to get bleeding-edge features
78+ at your own risk.
79+
80+ ---
8281
83- 3\. Give a proper name to your service and replace all the occurrences of "* service_template" string with that name:
82+ If you are planning to build userver as a subdirectory (not recommended generally),
83+ you can temporarily add userver scripts directory to ` PATH ` to bring the command into scope:
8484
8585``` shell
86- find . -not -path " ./third_party/* " -not - path " .git/* " -not -path ' ./build-* ' -type f | xargs sed -i ' s/service_template/YOUR_SERVICE_NAME/g '
86+ export PATH=/ path/to/userver/scripts: $PATH
8787```
8888
89- 4\. @ref ways_to_get_userver "Get userver".
90-
91- 5\. Build and test the service, see steps 3-4 from the @ref quick_start_for_beginners "updated instruction above".
92-
93- @anchor service_templates
94- ## Service templates for userver based services
89+ @anchor service_templates_run
90+ ### Creating a new service project
9591
9692To create a new service project, run:
9793
@@ -103,40 +99,21 @@ userver-create-service [--grpc] [--mongo] [--postgresql] myservice
10399* service name will be the last segment of the path;
104100* without feature flags, the service only has some stubs for HTTP handlers.
105101
106- If you use @ref devcontainers "Dev Containers", or if you @ref userver_cpm "use CPM to download userver",
107- run this script to get ` userver-create-service ` command:
108-
109- * Linux, macOS, BSD: @ref service-template/userver-create-service.sh
110- * Windows: @ref service-template/userver-create-service.bat
111-
112- In the script, replace ` vMAJOR.MINOR ` with the actual userver version, or use ` develop ` to get bleeding-edge features
113- at your own risk.
114-
115- If instead of installing userver you are planning to build userver as a subdirectory,
116- call the script from userver directory:
117-
118- ``` shell
119- path/to/userver/scripts/userver-create-service [--grpc] [--mongo] [--postgresql] myservice
120- ```
121-
122- You'll need to @ref ways_to_get_userver "get userver" before proceeding with local development.
123-
124102More information on the project directory structure can be found
125103@ref scripts/docs/en/userver/tutorial/hello_service.md "here".
126104
127105@anchor service_templates_libraries
128106### Using additional userver libraries in service templates
129107
130- The service templates allow to kickstart the development of your production-ready service,
131- but there can't be a repo for each and every combination of userver libraries.
132- To use additional userver libraries, e.g. ` userver::grpc ` , add to the root ` CMakeLists.txt ` :
108+ To use additional userver libraries, e.g. ` userver::kafka ` , add to the root ` CMakeLists.txt ` :
133109
134110``` cmake
135- find_package(userver COMPONENTS core grpc QUIET)
111+ find_package(userver COMPONENTS core kafka QUIET)
136112```
137113
138114Then add the corresponding option to @ref service_templates_presets "cmake presets",
139115e.g. ` "USERVER_FEATURE_GRPC": "ON" ` .
116+ (This allows to use @ref userver_cpm "CPM" with the service project.)
140117
141118@see @ref userver_libraries
142119
@@ -264,8 +241,8 @@ Some advice:
264241userver itself can be downloaded and built using CPM.
265242In fact, this is what `download_userver ()` function does in @ref service_templates " service templates" by default.
266243
267- ` download_userver()` just calls ` CPMAddPackage` with some defaults, so you can pin userver ` VERSION ` or ` GIT_TAG `
268- for reproducible builds.
244+ ` download_userver()` just forwards its arguments to ` CPMAddPackage` with some defaults,
245+ so you can pin userver ` VERSION ` or ` GIT_TAG ` for reproducible builds.
269246
270247When acquiring userver via CPM, you first need to install build dependencies. There are options:
271248
@@ -491,7 +468,7 @@ userver framework.
491468
492469You can start with @ref service_templates " service template" .
493470
494- If there a need to update the userver in the VM do the following:
471+ If there is a need to update userver in the VM, do the following:
495472
496473` ` ` bash
497474sudo apt remove libuserver-*
@@ -502,22 +479,12 @@ sudo git pull
502479sudo ./scripts/build_and_install_all.sh
503480` ` `
504481
505- # # PGO (clang)
506-
507- PGO compilation consists of 2 compilation stages: profile collecting and compilation with PGO.
508- You can use PGO compilation doing the following steps:
509-
510- 1) configure userver AND your service with cmake option ` -DUSERVER_PGO_GENERATE=ON` , compile the service;
511- 2) run the resulting binary under the production-like workload to collect profile;
512- 3) run llvm-profdata to convert profraw profile data format into profdata:
513- ` ` ` sh
514- llvm-profdata merge -output=code.profdata default.profraw
515- ` ` `
516- 4) configure userver AND your service with cmake option ` -DUSERVER_PGO_USE=< path_to_profdata> ` , compile the service.
517-
518- The resulting binary should be 2-15% faster than without PGO, depending on the code and workload.
519-
520- @see @ref cmake_options
482+ @cond
483+ Guideline for documentation authors:
484+ * this page is the main tutorial for getting from zero to building a basic service project as soon as possible;
485+ * for local build dependencies, use dependencies.md;
486+ * for advanced build flags, use options.md.
487+ @endcond
521488
522489----------
523490
0 commit comments