简体   繁体   中英

nohup process keep shutting down

I am trying to run 10.000 processes to create asterisks phone accounts. This is to stress-test our Asterisk server.

I called with php an exec() function to create a Linux command.

nohup /usr/src/pjproject-2.3/pjsip-apps/bin/pjsua-x86_64-unknown-linux-gnu --id=sip:%s@13.113.163.3 --registrar=sip:127.0.0.1:25060 --realm=* --username=%s --password=123456 --local-port=%s --null-audio --no-vad --max-calls=32 --no-tcp >>/dev/null 2>>/dev/null & $(echo -ne \'\r\')"

Everything works perfect and the script does exactly what I am expecting. But here comes also the next problem; after creating the 10.000 accounts, the processes are suddenly all getting killed.

Why is this?

Isn't it so that the nohup function keeps the processes alive? After calling the nohup function I am also calling the disown function.

Thank you for the help

[edit] I also tried this project with the function screen, the screen functions work like a charm, but the problem is the cpu usage. To create 10.000 screens, makes a linux server go nuts, this is why I choose for nohup.

The full php code:

<?php

# count
$count_screens = 0;

# port count start
$port_count = 30000; 

# register accounts number
$ext_number = 1000; 

# amount of times you want this loop to go
$min_accounts = 0;    
$max_accounts = 1000;          

Class shell {   

    const CREATE_SESSION  =    'screen -dmS stress[%s]';     
    const RUN_PJSUA       =    'screen -S stress[%s] -p 0 -rX stuff "nohup /usr/src/pjproject-2.3/pjsip-apps/bin/pjsua-x86_64-unknown-linux-gnu --id=sip:%s@13.113.163.3 --registrar=sip:127.0.0.1:25060 --realm=* --username=%s --password=123456 --local-port=%s --null-audio --no-vad --max-calls=32 --no-tcp >>/dev/null 2>>/dev/null &"';     
    const DISOWN_PJSUA    =    'screen -S stress[%s] -p 0 -rX stuff "disown -l $(echo -ne \'\r\')"';   

    public function openShell($count_screens) {   

        # creating a new screen to make the second call

        $command = sprintf(static:: CREATE_SESSION, $count_screens);  
        $string  = exec($command); 
        return var_dump($string);     

    } 

    public function runPJSUA($count_screens, $ext_number, $ext_number, $port_count) {  

        # register a new pjsua client 

        $command = sprintf(static:: RUN_PJSUA, $count_screens, $ext_number, $ext_number, $port_count);
        $string  = exec($command);  
        usleep(20000);  
        return var_dump($string); 

    }

    public function disownPJSUA($count_screens) {  

        # register a new pjsua client 

        $command = sprintf(static:: DISOWN_PJSUA, $count_screens); 
        $string  = exec($command);    
        return var_dump($string); 

    }

}  

while ($min_accounts < $max_accounts) {

    $shell = new shell(); 

    if ($count_screens == '0') {
        $count_screens++;
        echo $shell->openShell($count_screens); 
    } else {
        $count_screens = 1;
    }

    $port_count++; 
    $ext_number++; 
    $min_accounts++;  

    echo $shell->runPJSUA($count_screens, $ext_number, $ext_number, $port_count);
    echo $shell->disownPJSUA($count_screens);  

}

?>

Pjsua is relatively heavy application, definitely too heavy to run 10000 instances, not intended for this kind of testing. As you are configuring it for 32 calls even running out of ports would be a problem (there are two ports per call reserved plus port for SIP). If you want to stay with pjsua you might at least optimize test by configuring multiple accounts for single pjsua instance. It might be limited by command line length, but ~30 accounts per instance might work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM