本文整理汇总了PHP中unix_system_kill函数的典型用法代码示例。如果您正苦于以下问题:PHP unix_system_kill函数的具体用法?PHP unix_system_kill怎么用?PHP unix_system_kill使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unix_system_kill函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stop_sync_client
function stop_sync_client()
{
$unix = new unix();
if (!is_file($unix->CYRUS_SYNC_CLIENT_BIN_PATH())) {
return;
}
$pid = PID_NUM();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} - sync_client - service already stopped...\n";
}
return;
}
$pid = sync_client_pid();
$nohup = $unix->find_program("nohup");
$php5 = $unix->LOCATE_PHP5_BIN();
$kill = $unix->find_program("kill");
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} - sync_client - service Shutdown pid {$pid}...\n";
}
unix_system_kill($pid);
for ($i = 0; $i < 5; $i++) {
$pid = sync_client_pid();
if (!$unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} - sync_client - Service Waiting pid:{$pid} {$i}/5...\n";
}
sleep(1);
}
$pid = sync_client_pid();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} - sync_client - Service success...\n";
}
return;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} - sync_client - service Shutdown - force - pid {$pid}...\n";
}
unix_system_kill_force($pid);
for ($i = 0; $i < 5; $i++) {
$pid = sync_client_pid();
if (!$unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} - sync_client - service Waiting pid:{$pid} {$i}/5...\n";
}
sleep(1);
}
if ($unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} - sync_client - service Failed...\n";
}
return;
}
}
示例2: SERVICE_STOP
function SERVICE_STOP($aspid = false)
{
$unix = new unix();
$sock = new sockets();
$socket = "/var/run/mysqld/mysqld.sock";
$mysqlbin = $unix->LOCATE_mysqld_bin();
$php5 = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
$mysqladmin = $unix->find_program("mysqladmin");
$kill = $unix->find_program("kill");
$pgrep = $unix->find_program("pgrep");
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = @file_get_contents($pidfile);
$kill = $unix->find_program("kill");
if (!$aspid) {
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
echo "Stopping MySQL...............: This script is already executed PID: {$pid} since {$time}Mn\n";
if ($time < 5) {
if (!$GLOBALS["FORCE"]) {
return;
}
}
unix_system_kill_force($pid);
}
@file_put_contents($pidfile, getmypid());
}
$pid = PID_NUM();
if ($GLOBALS["VERBOSE"]) {
echo "DEBUG:: PID RETURNED {$pid}\n";
}
$unix->ToSyslog("MySQL: Stopping MySQL server");
if (!$unix->process_exists($pid, $mysqlbin)) {
echo "Stopping MySQL...............: Already stopped\n";
return;
}
$q = new mysql();
$q2 = new mysql_squid_builder();
$q2->MEMORY_TABLES_DUMP();
if (is_file($mysqladmin)) {
if (is_file($socket)) {
$cmds[] = "nohup";
$cmds[] = $mysqladmin;
$cmds[] = "--user={$q->mysql_admin}";
if ($q->mysql_password != null) {
$password = $q->mysql_password;
$password = $unix->shellEscapeChars($password);
$cmds[] = "--password={$password}";
}
$cmds[] = "--socket={$socket}";
$cmds[] = "shutdown";
$cmd = @implode(" ", $cmds);
$cmd = $cmd . " >/dev/null 2>&1 &";
echo "Stopping MySQL...............: Stopping smoothly mysqld pid:{$pid}\n";
if ($GLOBALS["VERBOSE"]) {
echo "[VERBOSE]: {$cmd}\n";
}
for ($i = 0; $i < 10; $i++) {
sleep(1);
$pid = PID_NUM();
if (!$unix->process_exists($pid, $mysqlbin)) {
break;
}
echo "Stopping MySQL...............: Stopping, please wait {$i}/10\n";
}
}
}
$pid = PID_NUM();
if (!$unix->process_exists($pid, $mysqlbin)) {
echo "Stopping MySQL...............: Stopped\n";
system_admin_events("Success to STOP MySQL server", __FUNCTION__, __FILE__, __LINE__, "services");
return;
}
mysql_admin_mysql(0, "Stopping MySQL service PID {$pid}", null, __FILE__, __LINE__);
echo "Stopping MySQL...............: killing smoothly PID {$pid}\n";
unix_system_kill($pid);
for ($i = 0; $i < 5; $i++) {
sleep(1);
$pid = PID_NUM();
if (!$unix->process_exists($pid, $mysqlbin)) {
break;
}
}
if (!$unix->process_exists($pid, $mysqlbin)) {
echo "Stopping MySQL...............: Stopped\n";
system_admin_events("Success to STOP MySQL server", __FUNCTION__, __FILE__, __LINE__, "services");
return;
}
echo "Stopping MySQL...............: Force killing PID {$pid}\n";
unix_system_kill_force($pid);
for ($i = 0; $i < 5; $i++) {
sleep(1);
$pid = PID_NUM();
if (!$unix->process_exists($pid, $mysqlbin)) {
break;
}
}
if (!$unix->process_exists($pid, $mysqlbin)) {
echo "Stopping MySQL...............: Stopped\n";
system_admin_events("Success to STOP MySQL server", __FUNCTION__, __FILE__, __LINE__, "services");
//.........这里部分代码省略.........
示例3: MultiplesInstances_stop
function MultiplesInstances_stop($hostname)
{
$unix = new unix();
$pid = MultiplesInstancesPID($hostname);
if (!$unix->process_exists($pid)) {
echo "{$GLOBALS["deflog_sstop"]} {$hostname} already stopped\n";
return;
}
echo "{$GLOBALS["deflog_sstop"]} {$hostname} stopping pid {$pid}\n";
unix_system_kill($pid);
for ($i = 0; $i < 20; $i++) {
$pid = MultiplesInstancesPID($hostname);
if (!$unix->process_exists($pid)) {
echo "{$GLOBALS["deflog_sstop"]} {$hostname} stopped\n";
break;
}
echo "{$GLOBALS["deflog_sstop"]} {$hostname} waiting pid {$pid}\n";
if ($unix->process_exists($pid)) {
unix_system_kill_force($pid);
sleep(1);
continue;
}
break;
}
}
示例4: stop
function stop($aspid = false)
{
$sock = new sockets();
$unix = new unix();
$GLOBALS["CLASS_UNIX"] = $unix;
if (!$aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Already task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
}
$pid = mailarchive_pid();
if (!$unix->process_exists($pid)) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: Mail Archiver already stopped...\n";
}
return;
}
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: Mail Archiver pid {$pid} (run since {$time}Mn)...\n";
}
$kill = $unix->find_program("kill");
unix_system_kill($pid);
for ($i = 0; $i < 5; $i++) {
$pid = mailarchive_pid();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method) stopped...\n";
}
break;
}
sleep(1);
}
$pid = mailarchive_pid();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method) success...\n";
}
@unlink("/var/run/maildump/maildump.socket");
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: Mail Archiver (Perl method) failed to stop..\n";
}
}
}
示例5: stop
function stop($aspid = false)
{
$unix = new unix();
if (!$aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service Already Artica task running PID {$pid} since {$time}mn\n";
}
build_progress_restart("{stopping_service} {failed}", 110);
return;
}
@file_put_contents($pidfile, getmypid());
}
$pid = $GLOBALS["MONIT_CLASS"]->PID_NUM();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service already stopped...\n";
}
build_progress_restart("{stopping_service} {success}", 20);
return true;
}
$pid = $GLOBALS["MONIT_CLASS"]->PID_NUM();
$nohup = $unix->find_program("nohup");
$php5 = $unix->LOCATE_PHP5_BIN();
$kill = $unix->find_program("kill");
build_progress_restart("{stopping_service}", 16);
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} unmonitor all processes\n";
}
exec($GLOBALS["MONIT_CLASS"]->stop_cmdline . " 2>&1", $results);
sleep(1);
build_progress_restart("{stopping_service}", 17);
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service Shutdown pid {$pid}...\n";
}
unix_system_kill($pid);
for ($i = 0; $i < 5; $i++) {
$pid = $GLOBALS["MONIT_CLASS"]->PID_NUM();
if (!$unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service waiting pid:{$pid} {$i}/5...\n";
}
sleep(1);
}
build_progress_restart("{stopping_service}", 18);
$pid = $GLOBALS["MONIT_CLASS"]->PID_NUM();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service success...\n";
}
build_progress_restart("{stopping_service} {success}", 20);
return true;
}
build_progress_restart("{stopping_service}", 19);
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service shutdown - force - pid {$pid}...\n";
}
unix_system_kill_force($pid);
for ($i = 0; $i < 5; $i++) {
$pid = $GLOBALS["MONIT_CLASS"]->PID_NUM();
if (!$unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service waiting pid:{$pid} {$i}/5...\n";
}
sleep(1);
}
if ($unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service failed...\n";
}
build_progress_restart("{stopping_service} {failed}", 110);
return false;
}
build_progress_restart("{stopping_service} {success}", 20);
return true;
}
示例6: stop
function stop($aspid = false)
{
$unix = new unix();
if (!$aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
}
$spawn_fcgi = $unix->find_program("spawn-fcgi");
if (!is_file($spawn_fcgi)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} not installed\n";
}
return;
}
$pid = DEFAULT_PID();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} already stopped...\n";
}
return;
}
$pid = DEFAULT_PID();
$nohup = $unix->find_program("nohup");
$php5 = $unix->LOCATE_PHP5_BIN();
$lighttpd_bin = $unix->find_program("lighttpd");
$kill = $unix->find_program("kill");
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Shutdown pid {$pid}...\n";
}
unix_system_kill($pid);
for ($i = 0; $i < 5; $i++) {
$pid = DEFAULT_PID();
if (!$unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} waiting pid:{$pid} {$i}/5...\n";
}
sleep(1);
}
$pid = DEFAULT_PID();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} success...\n";
}
return;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} shutdown - force - pid {$pid}...\n";
}
unix_system_kill_force($pid);
for ($i = 0; $i < 5; $i++) {
$pid = DEFAULT_PID();
if (!$unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} waiting pid:{$pid} {$i}/5...\n";
}
sleep(1);
}
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} success...\n";
}
return;
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} failed...\n";
}
}
}
示例7: stop
function stop()
{
$unix = new unix();
$sock = new sockets();
$masterbin = $unix->find_program("ntopng");
if (!is_file($masterbin)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Not installed\n";
}
return;
}
$pid = ntopng_pid();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Already stopped...\n";
}
return;
}
$nohup = $unix->find_program("nohup");
$php5 = $unix->LOCATE_PHP5_BIN();
$kill = $unix->find_program("kill");
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Shutdown pid {$pid}...\n";
}
unix_system_kill($pid);
for ($i = 0; $i < 5; $i++) {
$pid = ntopng_pid();
if (!$unix->process_exists($pid)) {
break;
}
unix_system_kill($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} waiting pid:{$pid} {$i}/5...\n";
}
sleep(1);
}
$pid = ntopng_pid();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} success...\n";
}
return;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} shutdown - force - pid {$pid}...\n";
}
unix_system_kill_force($pid);
for ($i = 0; $i < 5; $i++) {
$pid = ntopng_pid();
if (!$unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} waiting pid:{$pid} {$i}/5...\n";
}
unix_system_kill_force($pid);
sleep(1);
}
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} success stopped...\n";
}
return;
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} failed...\n";
}
}
}
示例8: stop_instance
function stop_instance($ID)
{
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".{$ID}.pid";
$pid = @file_get_contents($pidfile);
$unix = new unix();
if ($unix->process_exists($pid, basename(__FILE__))) {
echo "Starting......: " . date("H:i:s") . " load-balancer engine Already executed PID {$pid}...\n";
return;
}
@file_put_contents($pidfile, getmypid());
$unix = new unix();
$q = new mysql();
$kill = $unix->find_program("kill");
$pid = cross_pid($ID);
if (!$unix->process_exists($pid)) {
echo "Stopping Crossroads Daemon...: instance ID:{$ID} already stopped\n";
return;
}
echo "Stopping Crossroads Daemon...: instance ID:{$ID} PID {$pid}\n";
if (is_numeric($pid)) {
unix_system_kill($pid);
}
for ($i = 0; $i < 5; $i++) {
sleep(1);
if (!$unix->process_exists($pid)) {
echo "Stopping Crossroads Daemon...: instance ID:{$ID} stopped\n";
crossroads_events("Instance ID:{$ID} success to stop", $ID, __FUNCTION__, __LINE__);
return;
}
$pid = cross_pid($ID);
if (is_numeric($pid)) {
unix_system_kill($pid);
}
}
$pid = cross_pid($ID);
if ($unix->process_exists($pid)) {
echo "Stopping Crossroads Daemon...: instance ID:{$ID} Force to kill it !\n";
if (is_numeric($pid)) {
unix_system_kill_force($pid);
}
}
$pid = cross_pid($ID);
if ($unix->process_exists($pid)) {
echo "Stopping Crossroads Daemon...: instance ID:{$ID} failed\n";
crossroads_events("Unable to stop instance", $ID, __FUNCTION__, __LINE__);
} else {
echo "Stopping Crossroads Daemon...: instance ID:{$ID} success\n";
}
}
示例9: stop
function stop($aspid = false)
{
$unix = new unix();
if (!$aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
}
$pid = PID_NUM();
if (!$unix->process_exists($pid)) {
build_progress_rs("{stopping_service}", 30);
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service already stopped...\n";
}
return true;
}
$nohup = $unix->find_program("nohup");
$php5 = $unix->LOCATE_PHP5_BIN();
$kill = $unix->find_program("kill");
build_progress_rs("{stopping_service}", 15);
if (!ifInitScript()) {
shell_exec("{$php5} /usr/share/artica-postfix/exec.initslapd.php --influx");
}
$cmd = "/etc/init.d/influx-db stop";
if ($GLOBALS["VERBOSE"]) {
echo "{$cmd}\n";
}
shell_exec($cmd);
$pid = PID_NUM();
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service Shutdown pid {$pid}...\n";
}
unix_system_kill($pid);
for ($i = 0; $i < 5; $i++) {
build_progress_rs("{stopping_service}", 15 + $i);
$pid = PID_NUM();
if (!$unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service waiting pid:{$pid} {$i}/5...\n";
}
sleep(1);
}
if (test_listen_port()) {
for ($i = 0; $i < 5; $i++) {
build_progress_rs("{stopping_service} {waiting_port_to_be_closed}", 25);
if (!test_listen_port()) {
break;
}
if (!$unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service waiting socket {$i}/5...\n";
}
sleep(1);
}
}
$pid = PID_NUM();
if (!$unix->process_exists($pid)) {
build_progress_rs("{stopping_service}", 30);
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service success...\n";
}
return true;
}
build_progress_rs("{stopping_service}", 30);
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service shutdown - force - pid {$pid}...\n";
}
unix_system_kill_force($pid);
for ($i = 0; $i < 5; $i++) {
build_progress_rs("{stopping_service}", 30 + $i);
$pid = PID_NUM();
if (!$unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service waiting pid:{$pid} {$i}/5...\n";
}
sleep(1);
}
if ($unix->process_exists($pid)) {
build_progress_rs("{stopping_service} {failed}", 110);
squid_admin_mysql(0, "Failed to start Statistics Engine", __FILE__, __LINE__);
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service failed...\n";
}
return;
}
return true;
}
示例10: virtual_delete
function virtual_delete()
{
$unix = new unix();
$virtname = $_GET["virtual-delete"];
$nic = $_GET["nic"];
$pidfile = "/var/run/{$virtname}.pid";
$ipbin = $unix->find_program("ip");
$ifconfig = $unix->find_program("ifconfig");
$nohup = $unix->find_program("nohup");
$php5 = $unix->LOCATE_PHP5_BIN();
$pid = $unix->get_pid_from_file($pidfile);
$kill = $unix->find_program("kill");
if ($unix->process_exists($pid)) {
unix_system_kill($pid);
sleep(1);
}
if ($unix->process_exists($pid)) {
unix_system_kill_force($pid);
sleep(1);
}
$cmd = "{$ipbin} route flush table {$virtname}";
writelogs_framework("{$cmd}", __FUNCTION__, __FILE__, __LINE__);
shell_exec($cmd);
$cmd = "/usr/share/artica-postfix/bin/rt_tables.pl --remove-name {$virtname} >/dev/null 2>&1";
writelogs_framework("{$cmd}", __FUNCTION__, __FILE__, __LINE__);
shell_exec($cmd);
$cmd = "{$ifconfig} {$virtname} down";
writelogs_framework("{$cmd}", __FUNCTION__, __FILE__, __LINE__);
shell_exec($cmd);
$cmd = trim("{$nohup} {$php5} /usr/share/artica-postfix/exec.vde.php --reconfigure-switch {$nic} >/dev/null 2>&1 &");
writelogs_framework("{$cmd}", __FUNCTION__, __FILE__, __LINE__);
shell_exec($cmd);
}
示例11: stop
function stop($aspid = false)
{
$unix = new unix();
if (is_file("/etc/artica-postfix/FROM_ISO")) {
if ($unix->file_time_min("/etc/artica-postfix/FROM_ISO") < 1) {
return;
}
}
$scriptlog = null;
if ($GLOBALS["BYSCRIPT"]) {
$scriptlog = " by init.d script";
}
if (!$aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
}
$pid = LIGHTTPD_PID();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: Framework service already stopped...\n";
}
return;
}
$pid = LIGHTTPD_PID();
if ($GLOBALS["MONIT"]) {
@file_put_contents("/var/run/lighttpd/framework.pid", $pid);
return;
}
$nohup = $unix->find_program("nohup");
$php5 = $unix->LOCATE_PHP5_BIN();
$lighttpd_bin = $unix->find_program("lighttpd");
$kill = $unix->find_program("kill");
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: Framework shutdown pid {$pid}...\n";
}
unix_system_kill($pid);
for ($i = 0; $i < 5; $i++) {
$pid = LIGHTTPD_PID();
if (!$unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Framework service waiting pid:{$pid} {$i}/5...\n";
}
sleep(1);
}
$pid = LIGHTTPD_PID();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: Framework service success...\n";
}
killallphpcgi();
return;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: Framework shutdown - force - pid {$pid}...\n";
}
unix_system_kill_force($pid);
for ($i = 0; $i < 5; $i++) {
$pid = LIGHTTPD_PID();
if (!$unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Framework service waiting pid:{$pid} {$i}/5...\n";
}
sleep(1);
}
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: Framework service success...\n";
}
FrmToSyslog("Success service stopped {$scriptlog}");
killallphpcgi();
return;
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: Framework service failed...\n";
}
}
}
示例12: cgred_stop
function cgred_stop($nomypidcheck = false)
{
if ($GLOBALS["VERBOSE"]) {
echo "Starting......: " . date("H:i:s") . " cgroups: DEBUG:: " . __FUNCTION__ . " START\n";
}
$unix = new unix();
if (!$nomypidcheck) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = @file_get_contents($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$trace = debug_backtrace();
if (isset($trace[1])) {
$called = " called by " . basename($trace[1]["file"]) . " {$trace[1]["function"]}() line {$trace[1]["line"]}";
}
echo "Starting......: " . date("H:i:s") . " cgroups: cgred_stop() function Already running pid {$pid}, aborting {$called}\n";
return;
}
@file_put_contents($pidfile, getmypid());
}
$cgrulesengd = $unix->find_program("cgrulesengd");
$kill = $unix->find_program("kill");
if (!is_file($cgrulesengd)) {
echo "Stopping cgroups.............: CGroup Rules Engine Daemon no such binary\n";
return;
}
$pid = $unix->PIDOF($cgrulesengd);
if (!$unix->process_exists($pid)) {
echo "Stopping cgroups.............: CGroup Rules Engine Daemon already stopped\n";
return;
}
unix_system_kill($pid);
for ($i = 0; $i < 6; $i++) {
$pid = $unix->PIDOF($cgrulesengd);
if (!$unix->process_exists($pid)) {
break;
}
sleep(1);
}
$pid = $unix->PIDOF($cgrulesengd);
if (!$unix->process_exists($pid)) {
echo "Stopping cgroups.............: CGroup Rules Engine successfully stopped\n";
} else {
echo "Stopping cgroups.............: CGroup Rules Engine failed to stop\n";
}
}
示例13: stop
function stop($nopid = false)
{
$users = new usersMenus();
$unix = new unix();
if (!$users->ETTERCAP_INSTALLED) {
echo "ArpSpoofing.........: [STOP]: Ettercap, not installed...\n";
return;
}
$kill = $unix->find_program("kill");
if (!$nopid) {
$me = basename(__FILE__);
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, $me)) {
$time = $unix->PROCCESS_TIME_MIN($pid);
echo "ArpSpoofing.........: [START]: Ettercap, Already start instance executed PID {$pid} since {$time}Mn...\n";
return;
}
@file_put_contents($pidfile, getmypid());
}
$pids = GetAllPids();
if (count($pids) == 0) {
echo "ArpSpoofing.........: [STOP]: Ettercap, no instance in memory\n";
return;
}
while (list($pid, $ruleid) = each($pids)) {
echo "ArpSpoofing.........: [STOP]: stopping smoothly pid {$pid} for rule {$ruleid}\n";
unix_system_HUP($pid);
unix_system_kill($pid);
}
for ($i = 0; $i < 10; $i++) {
$pids = GetAllPids();
while (list($pid, $ruleid) = each($pids)) {
if (!$unix->process_exists($pid)) {
echo "ArpSpoofing.........: [STOP]: pid {$pid} for rule {$ruleid} stopped...\n";
unset($pids[$pid]);
continue;
}
echo "ArpSpoofing.........: [STOP]: pid {$pid} for rule {$ruleid} still alive...\n";
}
if (count($pids) == 0) {
break;
}
sleep(1);
}
$pids = GetAllPids();
if (count($pids) > 0) {
reset($pids);
while (list($pid, $ruleid) = each($pids)) {
echo "ArpSpoofing.........: [STOP]: pid {$pid} for rule {$ruleid} force stopping...\n";
unix_system_kill_force($pid);
}
}
$pids = GetAllPids();
if (count($pids) > 0) {
reset($pids);
while (list($pid, $ruleid) = each($pids)) {
echo "ArpSpoofing.........: [STOP]: pid {$pid} for rule {$ruleid} failed stopping...\n";
}
}
echo "ArpSpoofing.........: [STOP]: DONE...\n";
}
示例14: multiples_stop
function multiples_stop()
{
$GLOBALS["CLASS_UNIX"] = new unix();
$pgrep = $GLOBALS["CLASS_UNIX"]->find_program("pgrep");
$xr = $GLOBALS["CLASS_UNIX"]->find_program("xr");
$kill = $GLOBALS["CLASS_UNIX"]->find_program("kill");
$pattern = "{$pgrep} -l -f \"{$xr}\" 2>&1";
exec($pattern, $results);
while (list($index, $line) = each($results)) {
if ($GLOBALS["VERBOSE"]) {
echo "Stopping Crossroads Daemon...: {$line}\n";
}
if (preg_match("#^([0-9]+).+?pgrep#", $line)) {
if ($GLOBALS["VERBOSE"]) {
echo "Stopping Crossroads Daemon...: pgrep line, continue\n";
}
continue;
}
if (preg_match("#^([0-9]+).+?18501#", $line)) {
if ($GLOBALS["VERBOSE"]) {
echo "Stopping Crossroads Daemon...: Match master instance, continue\n";
}
continue;
}
if (!preg_match("#^([0-9]+)\\s+#", $line, $re)) {
continue;
}
if ($GLOBALS["VERBOSE"]) {
echo "Stopping Crossroads Daemon...: found pid: {$re[1]}\n";
}
if ($GLOBALS["CLASS_UNIX"]->process_exists($re[1])) {
echo "Stopping Crossroads Daemon...: multiple instance PID {$re[1]}\n";
unix_system_kill($re[1]);
for ($i = 0; $i < 5; $i++) {
sleep(1);
if (!$GLOBALS["CLASS_UNIX"]->process_exists($re[1])) {
echo "Stopping Crossroads Daemon...: multiple success PID {$re[1]}...\n";
break;
}
}
}
}
}
示例15: stop
function stop($aspid = false)
{
$unix = new unix();
if (!$aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
}
$pid = PID_NUM();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service already stopped...\n";
}
return;
}
$pid = PID_NUM();
$nohup = $unix->find_program("nohup");
$php5 = $unix->LOCATE_PHP5_BIN();
$kill = $unix->find_program("kill");
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service Shutdown pid {$pid}...\n";
}
unix_system_kill($pid);
for ($i = 0; $i < 5; $i++) {
$pid = PID_NUM();
if (!$unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service waiting pid:{$pid} {$i}/5...\n";
}
sleep(1);
}
$pid = PID_NUM();
if (!$unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service success...\n";
}
return;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service shutdown - force - pid {$pid}...\n";
}
unix_system_kill_force($pid);
for ($i = 0; $i < 5; $i++) {
$pid = PID_NUM();
if (!$unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service waiting pid:{$pid} {$i}/5...\n";
}
sleep(1);
}
if ($unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service failed...\n";
}
return;
}
$sock = new sockets();
$maillog_path = $sock->GET_INFO("maillog_path");
$tail = $unix->find_program("tail");
if (strlen($maillog_path) == 0) {
shell_exec("/usr/share/artica-postfix/bin/artica-install --whereis-maillog >/dev/null 2>&1");
$maillog_path = $sock->GET_INFO("maillog_path");
}
if (strlen($maillog_path) == 0) {
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Unable to find mail.log path\n";
}
return;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} mail.log: {$maillog_path}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} find ghost processes\n";
}
for ($i = 0; $i < 10; $i++) {
$pid = PID_NUM();
if (!$unix->process_exists($pid)) {
break;
}
if ($GLOBALS["OUTPUT"]) {
echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Kill ghost {$pid} process\n";
}
unix_system_kill_force($pid);
}
}