summaryrefslogtreecommitdiff
path: root/src/common/core.c
diff options
context:
space:
mode:
authorcelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-03-07 15:41:38 +0000
committercelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-03-07 15:41:38 +0000
commitec11a6a46dcb98508758d0fb96d18194f28450c5 (patch)
treef7d2d8aef6bc3ab7db6cafd610dcd6a3f8053110 /src/common/core.c
parent24ec5cc01a034fe378bc0e8dfb7426a2dbbf8563 (diff)
downloadhercules-ec11a6a46dcb98508758d0fb96d18194f28450c5.tar.gz
hercules-ec11a6a46dcb98508758d0fb96d18194f28450c5.tar.bz2
hercules-ec11a6a46dcb98508758d0fb96d18194f28450c5.tar.xz
hercules-ec11a6a46dcb98508758d0fb96d18194f28450c5.zip
* Added uptime logging support whenever the server closes
* Fixed 'make clean' not removing the .o files in /common git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1207 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/core.c')
-rw-r--r--src/common/core.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/common/core.c b/src/common/core.c
index a30445650..50fadf646 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -201,7 +201,9 @@ static void display_title(void)
*/
int runflag = 1;
+unsigned long ticks = 0; // by MC Cameri
char pid_file[256];
+char server_type[24];
void pid_delete(void) {
unlink(pid_file);
@@ -227,11 +229,46 @@ void pid_create(const char* file) {
}
}
+#define LOG_UPTIME 0
+void log_uptime()
+{
+#if LOG_UPTIME
+ time_t curtime;
+ char curtime2[24];
+ FILE *fp;
+ long seconds = 0, day = 24*60*60, hour = 60*60,
+ minute = 60, days = 0, hours = 0, minutes = 0;
+
+ fp = fopen("log/uptime.log","a");
+ if (fp) {
+ time(&curtime);
+ strftime(curtime2, 24, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+
+ seconds = (gettick()-ticks)/CLOCKS_PER_SEC;
+ days = seconds/day;
+ seconds -= (seconds/day>0)?(seconds/day)*day:0;
+ hours = seconds/hour;
+ seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
+ minutes = seconds/minute;
+ seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
+
+ fprintf(fp, "%s: %s uptime - %ld days, %ld hours, %ld minutes, %ld seconds.\n",
+ curtime2, server_type, days, hours, minutes, seconds);
+ fclose(fp);
+ }
+
+ return;
+#endif
+}
+
int main(int argc,char **argv)
{
int next;
+ sscanf(argv[0], "./%24[^\n]", server_type); // map/char/login?
+ atexit(log_uptime);
pid_create(argv[0]);
+
Net_Init();
do_socket();
@@ -253,6 +290,7 @@ int main(int argc,char **argv)
do_init_memmgr(argv[0]); // 一番最初に実行する必要がある
tick_ = time(0);
+ ticks = gettick();
do_init(argc,argv);
while(runflag){