Commit 7ee3c09e authored by Ophélie Gagnard's avatar Ophélie Gagnard

Modify the program to be run at boot time.

Improve first working version.
(Note: last version before the first test on the capri002.)
parent cb51d555
/root/metadata-collect-agent/target/x86_64-unknown-linux-musl/release/metadata-collect-agent
\ No newline at end of file
......@@ -54,8 +54,8 @@ nopython: main.cpp#$(EXE)
make fake_python.o
g++ -O2 -g -Wno-unused-result -Wsign-compare -pthread -I/usr/include/python3.7 main.cpp fake_python.o -lcrypto -lfmt -o metadata-collect-agent
#-ln -f ../../metadata-collect-agent metadata-collect-agent
-ln -f metadata-collect-agent ../../dracut.module/90metadata-collect/metadata-collect-agent
-ln -f metadata-collect-agent ../../debian.package.unsafe/unsafe-boot-metadata-collect-agent/sbin/metadata-collect-agent
#-ln -f metadata-collect-agent ../../dracut.module/90metadata-collect/metadata-collect-agent
#-ln -f metadata-collect-agent ../../debian.package.unsafe/unsafe-boot-metadata-collect-agent/sbin/metadata-collect-agent
%.cpp: %.pyx
@echo "[Cython Compiling $^ -> $@]"
......@@ -78,6 +78,11 @@ clean:
-rm -f *.o
-rm -f -r build
-rm -f *.json
-rm -f /var/log/metadata_collect.log
-rm -f metadata-collect-agent
-rm -f ../../dracut.module/90metadata-collect/metadata-collect-agent
-rm -f ../../debian.package.unsafe/unsafe-boot-metadata-collect-agent/sbin/metadata-collect-agent
-rm -rf logs
.PHONY: all run nopython runnopython clean
.PRECIOUS: %.cpp
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -5,6 +5,7 @@ from libcythonplus.list cimport cyplist
from libc.stdio cimport fprintf, fopen, fclose, fread, fwrite, FILE, stdout, printf, ferror
from runtime.runtime cimport SequentialMailBox, BatchMailBox, NullResult, Scheduler
from runtime.unistd cimport pid_t, execlp, fork, sleep
from stdlib.stat cimport Stat, dev_t
from stdlib.digest cimport MessageDigest, md5sum, sha1sum, sha256sum, sha512sum
......@@ -249,6 +250,20 @@ cdef cypclass SymlinkNode(Node):
cdef int start(string path) nogil:
cdef char* program_name = "fluentbit"
cdef char* arg1 = "-e"
cdef char* arg2 = "/home/test/work/90metadata-collect/fluentbit_wendelin.so"
cdef char* arg3 = "-c"
cdef char* arg4 = "/home/test/work/90metadata-collect/flb.conf"
cdef pid_t child_pid = -1 # DEBUG
child_pid = fork() # DEBUG
cdef int err
if child_pid == 0: # CHILD
err = execlp("/home/test/work/90metadata-collect/fluentbit", program_name, arg1, arg2, arg3, arg4, 0)
printf("ERROR with execlp() in CHILD: %d\n", err)
else: # PARENT
global scheduler
scheduler = Scheduler()
......@@ -280,16 +295,18 @@ cdef int start(string path) nogil:
node = consume active_node
result = fopen('result.json', 'w')
#""" # DEBUG
result = fopen('/var/log/metadata_collect.log', 'w')
if result is NULL:
return -1
fprintf(result, '[\n')
node.write_node(result)
fprintf(result, ' {}\n]\n')
fprintf(result, 'fluentbit_end\n')
fclose(result)
#""" # DEBUG
del scheduler
return 0
......@@ -297,5 +314,5 @@ cdef int start(string path) nogil:
cdef public int main() nogil:
return start(<char*>'.')
def python_main():
start(<char*>'.')
#def python_main():
# start(<char*>'.')
cdef extern from *:
ctypedef int pid_t
cdef extern from "<unistd.h>" nogil:
int execvp(const char *file, char *const argv[])
int execlp(const char *file, const char *arg, ...)
pid_t fork()
unsigned int sleep(unsigned int seconds)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment