userver-framework / service_template

Template of a C++ service that uses userver framework. Build, test and CI scripts ready

Home Page:https://userver.tech/da/d16/md_en_2userver_2tutorial_2hello__service.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installation issue on MacOS

georghegel opened this issue · comments

When trying to install userver/service_template on MacOS there are couple of issues:

1. Configure and Build.

The path third_party/userver/scripts/docs/en/deps/macos.md - simply doesn't exist and we should create macos.md file and copy-paste dependencies from here macos.html. Only after that we can use the mentioned command in documentation: brew install $(cat path/to/macos.md | tr '\n' ' ').

After the first step we should be aware that http-parser - is disabled and we cannot install it by brew or macport. We should go to this repo: https://github.com/nodejs/http-parser and clone it.
Steps after the cloning: cd http-parser and try make install. There's an issue that on MacOS there's no flag -D for install command. So we can replace it by -c, because we are moving files, not directories. After that make install should work and give us the lib.

Other dependencies, that not mentioned.

When we will try to build service_template we will have other problems, that haven't been mentioned anywhere - installation of libraries for python files. There's couple of them: pyyaml, voluptuous, jinja-2:
conda install anaconda::pyyaml && conda install conda-forge::voluptuous && conda install `anaconda::jinja2

2. Build and Run

Issue found here.

This command will not work because of the lacking userver-samples-hello_service target on Makefile.

mkdir build_release
cd build_release
cmake -DCMAKE_BUILD_TYPE=Release ..
make userver-samples-hello_service

I've fixed it by reading Makefile and finding similar target: make start-service_template or make service_template.

But after that this command will not work also (maybe it was issue only in my mac, don't really know)
./samples/hello_service/userver-samples-hello_service -c </path/to/static_config.yaml>
Given static_config.yaml won't be parsed, because of the newlines between fields and non initialized variables such as worker-threads or ports.

I fixed it in static_config.yaml in this way:

components_manager:
    task_processors:                  # Task processor is an executor for coroutine tasks
        main-task-processor:          # Make a task processor for CPU-bound coroutine tasks.
            worker_threads: 4         # Process tasks in 4 threads.
        fs-task-processor:            # Make a separate task processor for filesystem bound tasks.
            worker_threads: 1
    default_task_processor: main-task-processor
    components:                       # Configuring components that were registered via component_list
        server:
            listener:                 # configuring the main listening socket...
                port: 80            # ...to listen on this port and...
                task_processor: main-task-processor    # ...process incoming requests on this task processor.

And after all everything will compile and work well. I hope this issue will help someone and I didn't miss anything.

Thank a lot for your issue.
We improved some points:

  1. We have this file with deps: https://github.com/userver-framework/userver/blob/develop/scripts/docs/en/deps/macos.md
  2. We replaced old http-parser to llhttp.