summaryrefslogtreecommitdiff
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
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
-rw-r--r--Changelog-SVN.txt6
-rw-r--r--src/common/Makefile2
-rw-r--r--src/common/core.c38
-rw-r--r--src/common/core.h1
-rw-r--r--src/map/map.c5
-rw-r--r--src/map/map.h2
6 files changed, 47 insertions, 7 deletions
diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt
index a6c499e82..081c0b8cb 100644
--- a/Changelog-SVN.txt
+++ b/Changelog-SVN.txt
@@ -1,6 +1,12 @@
Date Added
03/07
+ * Added uptime logging support whenever the server closes, to enable change
+ the 0 to 1 in core.c [celest]
+ #define LOG_UPTIME 0
+ To-do: Add this as an option to log config
+ * Fixed 'make clean' not removing the .o files in /common [celest]
+
* Updated core and map-server to jA 1115~1137 [celest]
- Added monster_delay_damage to battle conf
- Increased some default settings in script conf
diff --git a/src/common/Makefile b/src/common/Makefile
index c387c2e01..c90940b94 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -20,4 +20,4 @@ obj/showmsg.o: showmsg.c showmsg.h
obj/strlib.o: strlib.c strlib.h utils.h
clean:
- rm -f *.o obj
+ rm -rf *.o obj
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){
diff --git a/src/common/core.h b/src/common/core.h
index bc2be02c2..23431f297 100644
--- a/src/common/core.h
+++ b/src/common/core.h
@@ -4,6 +4,7 @@
#define _CORE_H_
extern int runflag;
+extern unsigned long ticks;
int do_init(int,char**);
diff --git a/src/map/map.c b/src/map/map.c
index bcf6c83ad..f241c5fec 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -50,8 +50,6 @@
// maybe put basic macros to somewhere else
#define swap(a,b) ((a == b) || ((a ^= b), (b ^= a), (a ^= b)))
-unsigned long ticks = 0; // by MC Cameri
-
#ifndef TXT_ONLY
#include "mail.h" // mail system [Valaris]
@@ -167,6 +165,7 @@ char help_txt[256] = "conf/help.txt";
char wisp_server_name[24] = "Server"; // can be modified in char-server configuration file
int console = 0;
+
/*==========================================
* 全map鯖?計での接??設定
* (char鯖から送られてくる)
@@ -3422,8 +3421,6 @@ int do_init(int argc, char *argv[]) {
sprintf(tmp_output,"Server is '"CL_GREEN"ready"CL_RESET"' and listening on port '"CL_WHITE"%d"CL_RESET"'.\n\n", map_port);
ShowStatus(tmp_output);
- ticks = gettick();
-
return 0;
}
diff --git a/src/map/map.h b/src/map/map.h
index aa73b7a8b..1cae3dccc 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -788,8 +788,6 @@ int map_who(int fd);
void map_helpscreen(); // [Valaris]
int map_delmap(char *mapname);
-extern unsigned long ticks;
-
#ifndef TXT_ONLY
// MySQL