您的位置:首页 >> 编程开发 >> Java >> 应用服务器 >> 正文
应用服务器 RSS
 

监控一个web服务的讨论(如果weblogic服务死掉了,让其自动启动)

http://www.rdxx.com 05年07月27日 22:48 CSDN 我要投稿

 

最近,我们的web服务老是自动的就死掉了,为此,头儿让我们几个轮流值班,时刻注视web服务,如果web服务死掉了,我们需要立刻启动它.
这个方法,又劳民又伤才.谁都不愿意值班,怎么办?
我想了一下,写个监控web服务的程序不就得了?
可以有多种监控方式:
1:传统桌面程序.
2:b/s的监控程序.

先试验一个传统桌面程序.
先做个试验:监控foxmail.exe是否运行,如果没有运行,就启动它.
在系统的进程列表中,foxmail.exe中的进程名称为foxmail.exe,如果有名称为foxmail.exe的进程,这进行任何动作,否则启动它.

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include "Tlhelp32.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
Timer1->Enabled = true;
}
//---------------------------------------------------------------------------


void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
  try{
     HANDLE SnapShot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
     if (SnapShot == INVALID_HANDLE_VALUE)
        return;
    PROCESSENTRY32 ProcessInfo;
    ProcessInfo.dwSize=sizeof(ProcessInfo);
    BOOL Status=Process32First(SnapShot,&ProcessInfo);
    BOOL flag = false; //是否有foxmail.exe进程
    while(Status)
    {
         if(AnsiString(ProcessInfo.szExeFile).LowerCase() == "foxmail.exe")
        {
            flag = true;
        }
        Status=Process32Next(SnapShot,&ProcessInfo);
    }
    AnsiString tempTime = FormatDateTime("yyyy,mm,dd,hh:nn:ss", Now());
    if(!flag){
         AnsiString Exename = "D:\\Program Files\\Foxmail\\Foxmail.exe";
         ShellExecute(Handle,"open",Exename.c_str(),"","", SW_SHOW );
        Memo1->Lines->Add("restart this program at " + tempTime);
    }
    else{
        Memo1->Lines->Add("running at " + tempTime);
    }
    CloseHandle (SnapShot);
    }catch(...){

    }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
        Timer1->Enabled = false;       

9 7 3 1 2 3 4 4 8 :


 
 
打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站