FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sysadmin/src/HookInitializer.cpp at master · StarryInternet/sysadmin · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
StarryInternet
/
sysadmin
Public
Notifications
You must be signed in to change notification settings
Fork
8
Star
11
Code
Issues
10
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
sysadmin
/
src
/
HookInitializer.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
85 lines (74 loc) · 3.12 KB
Breadcrumbs
sysadmin
/
src
/
HookInitializer.cpp
Copy path
File metadata and controls
85 lines (74 loc) · 3.12 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#
include
"
HookInitializer.h
"
#
include
"
HookTable.h
"
#
include
"
HookUser.h
"
#
include
"
TemplaterRunner.h
"
#
include
"
ServiceScriptRunner.h
"
#
include
<
algorithm
>
#
include
<
log4cxx/logger.h
>
#
include
<
memory
>
namespace
{
log4cxx::LoggerPtr
spLogger
(log4cxx::Logger::getLogger(
"
HookInitializer
"
));
}
namespace
dm
=
decibel::messaging;
namespace
sp
=
std::placeholders;
std::shared_ptr<HookManager>
HookManagerFactory
(FullHooksConfig config,
dm::Reactor* reactor,
IConfigurator* sysadmin,
size_t
parallelHooks)
{
std::unique_ptr<HookTable>
pTable
(
new
HookTable);
for
(
const
auto
& templateConfig : config.
mTemplates
)
{
auto
templaterRunner = std::make_shared<TemplaterRunner>(reactor, config.
mTemplaterPath
,
templateConfig.
mPath
,
templateConfig.
mDestination
,
templateConfig.
mArguments
);
pTable->
Insert
(
HookUser
(templateConfig.
mName
,
HookType::
TEMPLATER
,
templateConfig.
mHooks
,
std::bind
(&FulfillHooks, sysadmin, sp::_1),
templaterRunner,
1
));
}
for
(
const
auto
& serviceConfig : config.
mServices
)
{
std::vector<std::string> fullPath = serviceConfig.
mArguments
;
fullPath.
insert
(fullPath.
begin
(), serviceConfig.
mPath
);
auto
servicesRunner = std::make_shared<ServiceScriptRunner>(reactor,
fullPath,
serviceConfig.
mRunOptions
);
pTable->
Insert
(
HookUser
(serviceConfig.
mName
,
HookType::
SERVICE
,
serviceConfig.
mHooks
,
std::bind
(&FulfillHooks, sysadmin, sp::_1),
servicesRunner,
serviceConfig.
mRunLevel
));
}
return
std::make_shared<HookManager>(
std::move
(pTable), parallelHooks);
}
folly::Future<std::vector<ConfigPair::Key>>
FulfillHooks
(IConfigurator* sysadmin,
const
HookUser::HookContainer& hooks)
{
std::vector<ConfigPair::Key> output;
for
(
const
auto
& hook : hooks)
{
if
(hook.
mKey
.
IsWildcard
())
{
output.
push_back
(
ConfigPair::Key
(hook.
mKey
));
}
else
{
auto
pair =
UnwrapSinglePair
(sysadmin->
Get
(hook.
mKey
));
if
(!pair && !hook.
mOptional
)
{
return
folly::makeFuture<std::vector<ConfigPair::Key>>(
HookUserError
(
"
Couldn't satisfy hook:
"
+ hook.
mKey
.
ToString
()));
}
else
if
(pair)
{
output.
push_back
(pair.
get
().
GetKey
());
}
}
}
return
folly::makeFuture
(
std::move
(output));
}
Back
|
FazBrowse Home
|
New Git URL