Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 846beab

Browse files
authored
Merge pull request #264 from tikikun/main
feat: Add destroy feature to nitro
2 parents 5b6fdcf + 6660b93 commit 846beab

File tree

5 files changed

+37
-3
lines changed

5 files changed

+37
-3
lines changed

controllers/llamaCPP.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ bool llamaCPP::loadModelImpl(const Json::Value &jsonBody) {
383383
gpt_params params;
384384

385385
// By default will setting based on number of handlers
386-
int drogon_thread = drogon::app().getThreadNum();
386+
int drogon_thread = drogon::app().getThreadNum() - 1;
387387
LOG_INFO << "Drogon thread is:" << drogon_thread;
388388
if (jsonBody) {
389389
params.model = jsonBody["llama_model_path"].asString();

controllers/processManager.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "processManager.h"
2+
#include <cstdlib>
3+
#include <trantor/utils/Logger.h>
4+
5+
void processManager::destroy(const HttpRequestPtr &req,
6+
std::function<void(const HttpResponsePtr &)> &&callback) {
7+
LOG_INFO << "Program is exitting, goodbye!";
8+
exit(0);
9+
return;
10+
};
11+
// Add definition of your processing function here

controllers/processManager.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#pragma once
2+
3+
#include <drogon/HttpController.h>
4+
#include <drogon/HttpTypes.h>
5+
6+
using namespace drogon;
7+
8+
class processManager : public drogon::HttpController<processManager> {
9+
public:
10+
METHOD_LIST_BEGIN
11+
// use METHOD_ADD to add your custom processing function here;
12+
// METHOD_ADD(processManager::get, "/{2}/{1}", Get); // path is
13+
// /processManager/{arg2}/{arg1}
14+
METHOD_ADD(processManager::destroy, "/destroy",
15+
Delete); // path is /processManager/{arg1}/{arg2}/list
16+
17+
METHOD_LIST_END
18+
// your declaration of processing function maybe like this:
19+
void destroy(const HttpRequestPtr &req,
20+
std::function<void(const HttpResponsePtr &)> &&callback);
21+
// void your_method_name(const HttpRequestPtr& req, std::function<void (const
22+
// HttpResponsePtr &)> &&callback, double p1, int p2) const;
23+
};

llama.cpp

main.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ int main(int argc, char *argv[]) {
3939
LOG_INFO << "Server started, listening at: " << host << ":" << port;
4040
LOG_INFO << "Please load your model";
4141
drogon::app().addListener(host, port);
42-
drogon::app().setThreadNum(thread_num);
42+
drogon::app().setThreadNum(thread_num + 1);
4343
LOG_INFO << "Number of thread is:" << drogon::app().getThreadNum();
4444

4545
drogon::app().run();

0 commit comments

Comments
 (0)