-
Notifications
You must be signed in to change notification settings - Fork 201
ENT-14275: Move cf-reactor to core #6263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
victormlg
wants to merge
1
commit into
cfengine:master
Choose a base branch
from
victormlg:cf-reactor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+215
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -46,6 +46,7 @@ SUBDIRS = \ | |
| cf-net \ | ||
| cf-secret \ | ||
| cf-watchd \ | ||
| cf-reactor \ | ||
| misc \ | ||
| python \ | ||
| ext \ | ||
|
|
||
This file contains hidden or 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,54 @@ | ||
| # | ||
| # Copyright 2026 Northern.tech AS | ||
| # | ||
| # This file is part of CFEngine 3 - written and maintained by Northern.tech AS. | ||
| # | ||
| # This program is free software; you can redistribute it and/or modify it | ||
| # under the terms of the GNU General Public License as published by the | ||
| # Free Software Foundation; version 3. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program; if not, write to the Free Software | ||
| # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | ||
| # | ||
| # To the extent this program is licensed as part of the Enterprise | ||
| # versions of CFEngine, the applicable Commercial Open Source License | ||
| # (COSL) may apply to this file if you as a licensee so wish it. See | ||
| # included file COSL.txt. | ||
| # | ||
| noinst_LTLIBRARIES = libcf-reactor.la | ||
|
|
||
| AM_CPPFLAGS = -I$(srcdir)/../libpromises -I$(srcdir)/../libntech/libutils \ | ||
| -I$(srcdir)/../libcfecompat \ | ||
| -I$(srcdir)/../libcfnet \ | ||
| $(OPENSSL_CPPFLAGS) \ | ||
| $(PCRE2_CPPFLAGS) \ | ||
| $(ENTERPRISE_CPPFLAGS) | ||
|
|
||
| AM_CFLAGS = $(CF3_CFLAGS) \ | ||
| $(DEBUG_CFLAGS) \ | ||
| $(OPENSSL_CFLAGS) \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
| $(ENTERPRISE_CFLAGS) | ||
|
|
||
| libcf_reactor_la_LIBADD = ../libpromises/libpromises.la | ||
|
|
||
| libcf_reactor_la_SOURCES = \ | ||
| cf-reactor.c | ||
|
|
||
| if !BUILTIN_EXTENSIONS | ||
| bin_PROGRAMS = cf-reactor | ||
| cf_reactor_LDADD = libcf-reactor.la | ||
| cf_reactor_SOURCES = | ||
| endif | ||
|
|
||
| CLEANFILES = *.gcno *.gcda | ||
|
|
||
| # | ||
| # Some basic clean ups | ||
| # | ||
| MOSTLYCLEANFILES = *~ *.orig *.rej | ||
This file contains hidden or 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,147 @@ | ||
| /* | ||
| Copyright 2026 Northern.tech AS | ||
|
|
||
| This file is part of CFEngine 3 - written and maintained by Northern.tech AS. | ||
|
|
||
| This program is free software; you can redistribute it and/or modify it | ||
| under the terms of the GNU General Public License as published by the | ||
| Free Software Foundation; version 3. | ||
|
|
||
| This program is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| GNU General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU General Public License | ||
| along with this program; if not, write to the Free Software | ||
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | ||
|
|
||
| To the extent this program is licensed as part of the Enterprise | ||
| versions of CFEngine, the applicable Commercial Open Source License | ||
| (COSL) may apply to this file if you as a licensee so wish it. See | ||
| included file COSL.txt. | ||
| */ | ||
|
|
||
|
|
||
| #include <platform.h> | ||
| #include <logging.h> | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include <writer.h> | ||
| #include <config.h> | ||
| #include <generic_agent.h> | ||
| #include <man.h> | ||
| #include <cleanup.h> | ||
| #include <prototypes3.h> | ||
|
|
||
| static const Component COMPONENT = | ||
| { | ||
| .name = "cf-reactor", | ||
| .website = CF_WEBSITE, | ||
| .copyright = CF_COPYRIGHT | ||
| }; | ||
|
|
||
| static const char *const CF_REACTOR_SHORT_DESCRIPTION = "CFEngine event reaction daemon"; | ||
|
|
||
| static const char *const CF_REACTOR_MANPAGE_LONG_DESCRIPTION = | ||
| "cf-reactor is a daemon reacting on events, currently only NOTIFY events from PostgreSQL."; | ||
|
|
||
| static const struct option OPTIONS[] = | ||
| { | ||
| {"debug", no_argument, 0, 'd'}, | ||
| {"no-fork", no_argument, 0, 'F'}, | ||
| {"log-level", required_argument, 0, 'g'}, | ||
| {"help", no_argument, 0, 'h'}, | ||
| {"inform", no_argument, 0, 'I'}, | ||
| {"timestamp", no_argument, 0, 'l'}, | ||
| {"verbose", no_argument, 0, 'v'}, | ||
| {"version", no_argument, 0, 'V'}, | ||
| {NULL, 0, 0, '\0'} | ||
| }; | ||
|
|
||
| static const char *const HINTS[] = | ||
| { | ||
| "Enable debugging output and run in foreground", | ||
| "Run as a foreground process (do not fork)", | ||
| "Specify how detailed logs should be. Possible values: 'error', 'warning', 'notice', 'info', 'verbose', 'debug'", | ||
| "Print the help message", | ||
| "Print basic information about actions being taken", | ||
| "Log timestamps on each line of log output", | ||
| "Output verbose information about the behaviour of the agent", | ||
| "Output the version of the software", | ||
| NULL | ||
| }; | ||
|
|
||
| int main(int argc, char *argv[]) | ||
| { | ||
| bool no_fork = false; | ||
|
|
||
| extern char *optarg; | ||
| int longopt_idx; | ||
| int c; | ||
| while ((c = getopt_long(argc, argv, "dFg:hIlMvV", | ||
| OPTIONS, &longopt_idx)) | ||
| != -1) | ||
| { | ||
| switch (c) | ||
| { | ||
| case 'd': | ||
| LogSetGlobalLevel(LOG_LEVEL_DEBUG); | ||
| no_fork = true; | ||
| break; | ||
|
|
||
| case 'F': | ||
| no_fork = true; | ||
| break; | ||
|
|
||
| case 'g': | ||
| LogSetGlobalLevelArgOrExit(optarg); | ||
| break; | ||
|
|
||
| case 'h': | ||
| { | ||
| Writer *w = FileWriter(stdout); | ||
| WriterWriteHelp(w, &COMPONENT, OPTIONS, HINTS, NULL, false, true); | ||
| FileWriterDetach(w); | ||
| } | ||
| DoCleanupAndExit(EXIT_SUCCESS); | ||
|
|
||
| case 'I': | ||
| LogSetGlobalLevel(LOG_LEVEL_INFO); | ||
| break; | ||
|
|
||
| case 'l': | ||
| LoggingEnableTimestamps(true); | ||
| break; | ||
|
|
||
| case 'M': | ||
| { | ||
| Writer *out = FileWriter(stdout); | ||
| ManPageWrite(out, "cf-reactor", time(NULL), | ||
| CF_REACTOR_SHORT_DESCRIPTION, | ||
| CF_REACTOR_MANPAGE_LONG_DESCRIPTION, | ||
| OPTIONS, HINTS, | ||
| NULL, false, | ||
| true); | ||
| FileWriterDetach(out); | ||
| DoCleanupAndExit(EXIT_SUCCESS); | ||
| } | ||
|
|
||
| case 'v': | ||
| LogSetGlobalLevel(LOG_LEVEL_VERBOSE); | ||
| no_fork = true; | ||
| break; | ||
|
|
||
| case 'V': | ||
| { | ||
| Writer *w = FileWriter(stdout); | ||
| GenericAgentWriteVersion(w); | ||
| FileWriterDetach(w); | ||
| } | ||
| DoCleanupAndExit(EXIT_SUCCESS); | ||
|
|
||
| } | ||
| } | ||
|
|
||
| return ReactorEnterpriseMain(no_fork); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really need any of these flags in the community version?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, when I built ubuntu-24 agent community without the flags, I got: