apache / celix

Apache Celix is a framework for C and C++14 to develop dynamic modular software applications using component and in-process service-oriented programming.
https://celix.apache.org/
Apache License 2.0
162 stars 86 forks source link

http_admin web can not visit #592

Closed tonychen0924 closed 1 year ago

tonychen0924 commented 1 year ago

my feature : I wan to use web to manage celix bundle , such as lb,install in web .

When I build celix successfully , then run http_admin

  1. shell content: $ cd celix/build/deploy/c_examples/http_example_cnt $ ./http_example_cnt HTTP Admin started at port 8080 -> [2023-07-20T10:34:19] [ info] [celix_framework] [framework_start:481] Celix framework started $ ps -ef|grep http_example_cnt tony 25102 1664 0 Jul19 tty15 00:00:00 ./http_example_cnt tony 25108 1664 0 Jul19 tty15 00:00:00 ./http_example_cnt tony 25367 1664 0 Jul19 tty15 00:00:00 ./http_example_cnt tony 25559 1664 0 Jul19 tty15 00:00:00 ./http_example_cnt tony 26336 1664 0 Jul19 tty15 00:00:00 ./http_example_cnt tony 5741 1664 0 Jul19 tty15 00:00:00 ./http_example_cnt tony 5857 1664 0 Jul19 tty15 00:00:00 ./http_example_cnt tony 6302 1664 0 10:34 tty15 00:00:00 ./http_example_cnt tony 6308 6283 0 10:45 tty17 00:00:00 grep --color=auto http_example_cnt 2.Then I input "localhost:8080" web browse , but browser unresponsive

NOTE: My operations are all based on “celix/examples/celix-examples/http_example/README.md”

PengZheng commented 1 year ago

It seems that you have many instances of http_exmaple_cnt running in the background. For this example, you only need one instance running in foreground. Kill all these instances, and then keep one instance in foreground. You should be able to enter lb command for a foreground instance like this:

 ./http_example_cntd 
HTTP Admin started at port 8080
-> [2023-07-20T13:53:44] [   info] [celix_framework] [framework_start:481] Celix framework started
-> lb
  Bundles:
  ID    State        Name                                     Group               
  0     ACTIVE       Celix Framework                          Celix/Framework     
  1     ACTIVE       Apache Celix HTTP Admin                  Celix/HTTP_admin    
  2     ACTIVE       Apache Celix C Shell                     Celix/Shell         
  3     ACTIVE       Apache Celix Shell WUI                   Celix/Shell         
  4     ACTIVE       Apache Celix Shell TUI                   Celix/Shell         
  5     ACTIVE       Apache Celix HTTP Example                                    

->  # Here you should have a prompt

Normally, HTTP server should run as a background daemon. But this example serves to show that shell can be used via both CLI and web. If you really want to run it in background, just remove TUI bundle from the container.

tonychen0924 commented 1 year ago

Ok,After kill other same process ,it can visit successfully . thanks for your answer .

i found must use command "quit" to quit . If quit with "ctrl+c" or "ctrl+r" , it will course muti process are running . I suggest whether to consider adding these two signals because it is more in line with the exit habit of the program ?

PengZheng commented 1 year ago

i found must use command "quit" to quit . If quit with "ctrl+c" or "ctrl+r" , it will course muti process are running . I suggest whether to consider adding these two signals because it is more in line with the exit habit of the program ?

I check the example on my machine, ctrl+c worked as expected. I also checked the source code, and founded that SIGINT is dealt with the following:

https://github.com/apache/celix/blob/456de193fbdc07e02bd7afa0d7cf4e22c67dbe0d/libs/framework/src/celix_launcher.c#L123-L132

https://github.com/apache/celix/blob/456de193fbdc07e02bd7afa0d7cf4e22c67dbe0d/bundles/shell/shell_tui/src/shell_tui.c#L167-L208

If it still does not work on your machine, you can reopen this and add more contextual information to help us find the root cause. Of course, you can investigate it yourself. A bug fixing pull request is always welcomed.

PS: ctrl+r usually means reverse history search, and is not the expected way of quitting.