forked from linuxkerneltravel/lmp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'linuxkerneltravel:develop' into develop
- Loading branch information
Showing
4 changed files
with
159 additions
and
1 deletion.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <cpprest/http_client.h> | ||
#include <cpprest/json.h> | ||
|
||
using namespace web; | ||
using namespace web::http; | ||
using namespace web::http::client; | ||
|
||
int main() { | ||
utility::string_t url = U("http://0.0.0.0:8080/data"); // 替换为你的API URL | ||
|
||
http_client client(url); | ||
|
||
json::value postData; | ||
postData[U("key")] = json::value::string(U("value")); // 替换为你要发送的数据 | ||
|
||
http_request request(methods::POST); | ||
request.headers().set_content_type(U("application/json")); | ||
request.set_body(postData); | ||
|
||
client.request(request).then([](http_response response) { | ||
if (response.status_code() == status_codes::OK) { | ||
// 处理成功响应 | ||
// response.extract_json() 可以用于处理响应的JSON数据 | ||
} else { | ||
// 处理错误响应 | ||
} | ||
}).wait(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# 1.21 | ||
|
||
## server | ||
|
||
```shell | ||
git clone https://github.com/grafana/pyroscope.git | ||
cd pyroscope | ||
wget https://cdn.cypress.io/desktop/12.11.0/linux-x64/cypress.zip | ||
unzip cypress.zip | ||
tar -zcvf cypress.tar.gz cypress | ||
yarn add cypress.tar.gz | ||
make build | ||
./pyroscope # server | ||
|
||
./profilecli canary-exporter # run test agent in other shell | ||
# port for the HTTP(S) server used for data ingestion and web UI | ||
# address of the pyroscope server | ||
# default http://localhost:4040 | ||
|
||
``` | ||
|
||
## agent | ||
|
||
构建 | ||
|
||
```shell | ||
git clone https://github.com/grafana/agent.git | ||
make agent-flow | ||
cd build | ||
``` | ||
|
||
将以下配置保存到 config.river | ||
|
||
```r | ||
pyroscope.ebpf "instance" { | ||
forward_to = [pyroscope.write.endpoint.receiver] | ||
targets_only = false | ||
default_target = {"service_name" = "ebpf_profile"} | ||
} | ||
|
||
pyroscope.write "endpoint" { | ||
endpoint { | ||
url = "http://localhost:4040" | ||
} | ||
} | ||
``` | ||
|
||
运行 | ||
|
||
```shell | ||
sudo ./grafana-agent-flow run config.river | ||
/<path>/<to>/<pyroscope>/pyroscope | ||
# port for the HTTP(S) server used for data ingestion and web UI | ||
# address of the pyroscope server | ||
# default http://localhost:4040 | ||
``` | ||
|
||
# 0.36 | ||
|
||
```shell | ||
sudo ./pyroscope server | ||
sudo ./pyroscope ebpf | ||
# port for the HTTP(S) server used for data ingestion and web UI | ||
# address of the pyroscope server | ||
# default http://localhost:4040 | ||
``` | ||
|
||
# yarn install package from local folder | ||
|
||
如果您想在本地文件夹中安装 yarn 包,您可以使用以下命令: | ||
|
||
首先,需要将本地文件夹打包成 tar 压缩包。您可以使用以下命令: | ||
|
||
```shell | ||
tar -zcvf package_name.tar.gz /path/to/local/folder | ||
``` | ||
|
||
然后,您可以使用以下命令在项目根目录中安装本地 tar 包: | ||
|
||
```shell | ||
yarn add file:/path/to/package_name.tar.gz | ||
``` | ||
|
||
这将解压 tar 包并将其安装到项目的 node_modules 文件夹中。 | ||
|
||
请注意,安装本地 tar 包不是 yarn 的推荐方法,因此在生产环境中使用时请谨慎。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <cpprest/http_listener.h> | ||
#include <cpprest/json.h> | ||
|
||
using namespace web; | ||
using namespace web::http; | ||
using namespace web::http::experimental::listener; | ||
|
||
void handle_post(http_request request) { | ||
request.extract_json().then([&request](json::value body) { | ||
// 处理收到的JSON数据 | ||
// body 变量包含从客户端发送过来的JSON数据 | ||
std::cout << body << std::endl; | ||
// 返回成功响应 | ||
request.reply(status_codes::OK); | ||
}).wait(); | ||
} | ||
|
||
int main() { | ||
http_listener listener("http://0.0.0.0:8080/data"); // 替换为你想要监听的URL | ||
listener.support(methods::POST, handle_post); | ||
|
||
try { | ||
listener.open().then([]() { | ||
// 服务器启动成功 | ||
}).wait(); | ||
|
||
std::cout << "Server running..." << std::endl; | ||
|
||
// 阻塞直到用户按下任意键退出程序 | ||
std::cout << "Press Enter to exit..." << std::endl; | ||
std::string line; | ||
std::getline(std::cin, line); | ||
|
||
listener.close().then([]() { | ||
// 服务器关闭成功 | ||
}).wait(); | ||
} catch (std::exception const & e) { | ||
std::wcout << e.what() << std::endl; | ||
} | ||
|
||
return 0; | ||
} |