From f93f39b907959e3f5c4e7b7557af1764b1bc18c4 Mon Sep 17 00:00:00 2001 From: holishing Date: Mon, 25 Nov 2019 22:27:06 +0800 Subject: [PATCH 1/3] split unix socket daemon as another pid file --- maple/bbsd.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/maple/bbsd.c b/maple/bbsd.c index c5cc1268b..b5fa628b5 100644 --- a/maple/bbsd.c +++ b/maple/bbsd.c @@ -24,6 +24,8 @@ #define QLEN 3 #define PID_FILE "run/bbs.pid" +#define PID_FILE_INET "run/bbs_inet.pid" +#define PID_FILE_UNIXSOCKET "run/bbs_unixsocket.pid" #define LOG_FILE "run/bbs.log" #undef SERVER_USAGE @@ -1442,7 +1444,7 @@ start_daemon( /* mport = port; */ /* Thor.990325: ¤£»Ý­n¤F:P */ sprintf(data, "%d\t%s\t%d\tinetd -i\n", getpid(), buf, port); - f_cat(PID_FILE, data); + f_cat(PID_FILE_INET, data); return; } @@ -1531,8 +1533,17 @@ start_daemon( //sprintf(data, "%d\t%s\t%d\n", getpid(), buf, port); //f_cat(PID_FILE, data); - sprintf(data, "%d\n", getpid()); - f_cat(PID_FILE, data); + + if (port == -2) + { + sprintf(data, "%d\n", getpid()); + f_cat(PID_FILE_UNIXSOCKET, data); + } + else + { + sprintf(data, "%d\n", getpid()); + f_cat(PID_FILE, data); + } } From af87fd6753b6fde6568d38028d5240a9c1738f83 Mon Sep 17 00:00:00 2001 From: holishing Date: Wed, 27 Nov 2019 13:36:40 +0800 Subject: [PATCH 2/3] maple/bbsd.c: merge duplicated sprintf() --- maple/bbsd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/maple/bbsd.c b/maple/bbsd.c index b5fa628b5..92c905192 100644 --- a/maple/bbsd.c +++ b/maple/bbsd.c @@ -1532,16 +1532,14 @@ start_daemon( setuid(BBSUID); //sprintf(data, "%d\t%s\t%d\n", getpid(), buf, port); - //f_cat(PID_FILE, data); + sprintf(data, "%d\n", getpid()); if (port == -2) { - sprintf(data, "%d\n", getpid()); f_cat(PID_FILE_UNIXSOCKET, data); } else { - sprintf(data, "%d\n", getpid()); f_cat(PID_FILE, data); } } From f1148f2a414a592a48dd2cb45f46e5db02fca0fe Mon Sep 17 00:00:00 2001 From: holishing Date: Wed, 27 Nov 2019 14:07:08 +0800 Subject: [PATCH 3/3] update systemd service --- sample/bbsd.service | 4 ++-- sample/bbsd_unixsocket.service | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 sample/bbsd_unixsocket.service diff --git a/sample/bbsd.service b/sample/bbsd.service index c46917381..d8e05f9f8 100644 --- a/sample/bbsd.service +++ b/sample/bbsd.service @@ -1,12 +1,13 @@ [Unit] Description=DreamBBS Telnet server After=syslog.target network.target remote-fs.target nss-lookup.target +Requires=startbbs.service [Service] Type=forking PIDFile=/home/bbs/run/bbs.pid ExecStart=/home/bbs/bin/bbsd 23 & -ExecStop=/bin/kill -s QUIT $MAINPID +ExecStop=/bin/kill -s TERM $MAINPID Restart=on-failure RestartSec=42s KillMode=process @@ -15,4 +16,3 @@ PrivateTmp=true [Install] WantedBy=multi-user.target WantedBy=xchatd.service -Requires=startbbs.service diff --git a/sample/bbsd_unixsocket.service b/sample/bbsd_unixsocket.service new file mode 100644 index 000000000..8b8c9d4ef --- /dev/null +++ b/sample/bbsd_unixsocket.service @@ -0,0 +1,19 @@ +[Unit] +Description=DreamBBS Unixsocket server +After=syslog.target network.target remote-fs.target nss-lookup.target +Requires=startbbs.service + +[Service] +User=bbs +Group=bbs +Type=forking +PIDFile=/home/bbs/run/bbs_unixsocket.pid +ExecStart=/home/bbs/bin/bbsd -u run/bbsd.socket & +ExecStop=/bin/kill -s TERM $MAINPID +Restart=on-failure +RestartSec=42s +KillMode=process +PrivateTmp=true + +[Install] +WantedBy=multi-user.target