Commit 79e5d095 authored by Ophélie Gagnard's avatar Ophélie Gagnard

Add information messages to be displayed at boot time in the supported VMs.

Add a wait() call in main to improve fluent-bit behavior.
(Note: first working version with UEFI.)
parent 8fe62f55
......@@ -6,7 +6,7 @@ define collect_sh :=
/sbin/metadata-collect-agent "$$NEWROOT"
sleep 120
sleep 10
endef
......
......@@ -54,7 +54,7 @@ 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 ../../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
......
......@@ -2,10 +2,11 @@
from libcythonplus.list cimport cyplist
from libc.stdio cimport fprintf, fopen, fclose, fread, fwrite, FILE, stdout, printf, ferror
from libc.stdio cimport fprintf, fopen, fclose, fread, fwrite, FILE, stdout, stderr, printf, ferror
from runtime.runtime cimport SequentialMailBox, BatchMailBox, NullResult, Scheduler
from runtime.unistd cimport pid_t, execlp, fork, sleep
from runtime.wait cimport wait, waitpid
from stdlib.stat cimport Stat, dev_t
from stdlib.digest cimport MessageDigest, md5sum, sha1sum, sha256sum, sha512sum
......@@ -251,19 +252,26 @@ cdef cypclass SymlinkNode(Node):
cdef int start(string path) nogil:
printf("TEST TEST TEST TEST TEST\n\n") # DEBUG
cdef pid_t wait_error = -1 # DEBUG
cdef char* program_name = "fluentbit"
cdef char* arg1 = "-e"
cdef char* arg2 = "/root/metadata-collect-agent/dracut.module/90metadata-collect/fluentbit_wendelin.so"
cdef char* arg2 = "/etc/fluentbit_wendelin.so"
cdef char* arg3 = "-c"
cdef char* arg4 = "/root/metadata-collect-agent/dracut.module/90metadata-collect/flb.conf"
cdef char* arg4 = "/etc/flb.conf"
cdef pid_t child_pid = -1 # DEBUG
child_pid = fork() # DEBUG
cdef int err
if child_pid == 0: # CHILD
err = execlp("/root/metadata-collect-agent/dracut.module/90metadata-collect/fluent-bit", program_name, arg1, arg2, arg3, arg4, 0)
printf("ERROR with execlp() in CHILD: %d\n", err)
err = execlp("/sbin/fluent-bit", program_name, arg1, arg2, arg3, arg4, 0)
fprintf(stderr, "ERROR with execlp() in CHILD: %d\n", err)
else: # PARENT
printf("WELCOME TO PARENT\n\n") # DEBUG
sleep(2) # TODO error handling ; check if a wait can be made to wait for the child to perform execlp() (instead of the sleep)
global scheduler
scheduler = Scheduler()
......@@ -300,6 +308,8 @@ cdef int start(string path) nogil:
if result is NULL:
return -1
printf("WRITE_NOTE STAGE\n\n") # DEBUG
fprintf(result, '[\n')
node.write_node(result)
fprintf(result, ' {}\n]\n')
......@@ -309,6 +319,14 @@ cdef int start(string path) nogil:
#""" # DEBUG
del scheduler
fprintf(stderr, "WAITING [error version]\n\n")
printf("WAITING...\n\n")
wait_error = wait(NULL) # TODO improve this call (error handling, etc.)
#wait_error = waitpid(child_pid, NULL, 1) # TODO improve this call (error handling, etc.)
fprintf(stderr, "WAITING ENDS [error version]\n\n")
printf("WAITING ENDS NOW!\n\n")
return 0
cdef public int main() nogil:
......
from runtime.unistd cimport pid_t
cdef extern from "<wait.h>" nogil:
pid_t wait(int *wstatus)
pid_t waitpid(pid_t pid, int *wstatus, int options);
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