Four Js Development Tools Forum

Discussions by product => Genero BDL => Topic started by: Stefan S. on November 27, 2014, 01:41:03 pm



Title: Checking running Genero-Programs on Client-Side
Post by: Stefan S. on November 27, 2014, 01:41:03 pm
Hello,

If Programs running in container Mode I can check if there are running childs of the container before stopping the Parent-Program
(IF ui.Interface.getChildCount()>0 THEN    …)

That’s OK and works fine.

Is the a way to check the same, without running the Program in Container-Mode ?

In our case the user has first to Close all Programs before closing our Menu-Program.

(We don’t want to check running processes on the Server-Side or set those Information in a database table)

Thanks in Advance.

Kind regards


Stefan Serwe





Title: Re: Checking running Genero-Programs on Client-Side
Post by: Anderson P. on December 04, 2014, 12:46:14 pm
Interesting question... I have two similar cases, in one of them i need to check if the program is already running, because users must only run one instance of the program. In the other case, i run multiple instances of a program for performance propose (each instance connect to one of multiple servers to run some querys) and i need to control the amount of instances to avoid a overload.

In both cases i check the processes on the server side using the "ps -ef" Linux command, but will be better to have a built-in command to check this.


Title: Re: Checking running Genero-Programs on Client-Side
Post by: Lionel F. on December 10, 2014, 02:43:44 pm
Hi Stefan, Hi Anderson,

Since each process is independent, there is no easy solution and there is no existing frontcall achieving this on the client side.

The only suggestion I have is to add a popup menu when closing your menu application for asking user to check that other programs are correctly closed and that he really wants to quit.

Best regards,
Lionel 


Title: Re: Checking running Genero-Programs on Client-Side
Post by: Anderson P. on December 10, 2014, 04:13:32 pm
Well, in that case i will leave my contribution with the function we use here to count running instances of a given program, using a Linux command...

You basically do a ps -ef and grep the program name, read the response and discard lines with the program name that don't actually indicate that the program is running. Replace <program name> with the name of the program you want to count.

Code
  1. private function count()
  2.  
  3.    define l_command    string
  4.    define l_line       string
  5.    define ch           base.Channel
  6.    define l_count      smallint
  7.    define l_aux        string
  8.  
  9.    let l_count = 0
  10.    let ch = base.Channel.create()
  11.  
  12.    let l_command = 'ps -ef | grep <program name>'
  13.  
  14.    call ch.openPipe(l_command, "r")
  15.  
  16.    while ch.read(l_line)
  17.  
  18.        if   l_line.getIndexOf("gsproxy-bin",1) > 0 or
  19.             l_line.getIndexOf(l_aux,1) > 0 or
  20.             l_line.getIndexOf("sh -c ps -ef",1) > 0 or
  21.             l_line.getIndexOf("grep <program name>",1) > 0
  22.          then
  23.             continue while
  24.        end if
  25.  
  26.        let l_count = l_count + 1
  27.  
  28.    end while
  29.  
  30.    call ch.close()
  31.  
  32.    return l_count
  33.  
  34. end function
  35.