Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
dde36bfb
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dde36bfb
编写于
12月 03, 1999
作者:
T
Tatsuo Ishii
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Create postmaster.pid and postmaster.opts under $PGDATA
上级
9de156f1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
172 addition
and
3 deletion
+172
-3
src/backend/postmaster/postmaster.c
src/backend/postmaster/postmaster.c
+172
-3
未找到文件。
src/backend/postmaster/postmaster.c
浏览文件 @
dde36bfb
...
...
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.12
7 1999/10/25 03:07:45 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.12
8 1999/12/03 06:26:34 ishii
Exp $
*
* NOTES
*
...
...
@@ -92,6 +92,23 @@
#include "utils/trace.h"
#include "version.h"
/*
* "postmaster.pid" is a file containing postmaster's pid, being
* created uder $PGDATA upon postmaster's starting up. When postmaster
* shuts down, it will be unlinked. The purpose of the file includes:
*
* (1) supplying neccessary information to stop/restart postmaster
* (2) preventing another postmaster process starting while it has
* already started
*/
#define PIDFNAME "postmaster.pid"
/*
* "postmaster.opts" is a file containing options for postmaser.
* pg_ctl will use it to restart postmaster.
*/
#define OPTSFNAME "postmaster.opts"
#if !defined(MAXINT)
#define MAXINT INT_MAX
#endif
...
...
@@ -261,6 +278,15 @@ static void RandomSalt(char *salt);
static
void
SignalChildren
(
SIGNAL_ARGS
);
static
int
CountChildren
(
void
);
static
int
SetPidFile
(
pid_t
pid
,
char
*
progname
,
int
port
,
char
*
datadir
,
int
assert
,
int
nbuf
,
char
*
execfile
,
int
debuglvl
,
int
netserver
,
#ifdef USE_SSL
int
securenetserver
,
#endif
int
maxbackends
,
int
reinit
,
int
silent
,
int
sendstop
,
char
*
extraoptions
);
extern
int
BootstrapMain
(
int
argc
,
char
*
argv
[]);
static
pid_t
SSDataBase
(
bool
startup
);
#define StartupDataBase() SSDataBase(true)
...
...
@@ -272,11 +298,11 @@ static void InitSSL(void);
#ifdef CYR_RECODE
void
GetCharSetByHost
(
char
*
,
int
,
char
*
);
#endif
#ifdef USE_ASSERT_CHECKING
int
assert_enabled
=
1
;
int
assert_enabled
=
1
;
#endif
...
...
@@ -351,6 +377,9 @@ PostmasterMain(int argc, char *argv[])
bool
DataDirOK
;
/* We have a usable PGDATA value */
char
hostbuf
[
MAXHOSTNAMELEN
];
int
nonblank_argc
;
char
original_extraoptions
[
MAXPGPATH
];
*
original_extraoptions
=
'\0'
;
/*
* We need three params so we can display status. If we don't get
...
...
@@ -509,6 +538,7 @@ PostmasterMain(int argc, char *argv[])
*/
strcat
(
ExtraOptions
,
" "
);
strcat
(
ExtraOptions
,
optarg
);
strcpy
(
original_extraoptions
,
optarg
);
break
;
case
'p'
:
/* Set PGPORT by hand. */
...
...
@@ -618,6 +648,33 @@ PostmasterMain(int argc, char *argv[])
if
(
silentflag
)
pmdaemonize
();
/*
* create pid file. if the file has already existed, exits.
*/
if
(
SetPidFile
(
getpid
(),
/* postmaster process id */
progname
,
/* postmaster executable file */
PostPortName
,
/* port number */
DataDir
,
/* PGDATA */
assert_enabled
,
/* whether -A is specified or not */
NBuffers
,
/* -B: number of shared buffers */
Execfile
,
/* -b: postgres executable file */
DebugLvl
,
/* -d: debug level */
NetServer
,
/* -i: accept connection from INET */
#ifdef USE_SSL
SecureNetServer
,
/* -l: use SSL */
#endif
MaxBackends
,
/* -N: max number of backends */
Reinit
,
/* -n: reinit shared mem after failure */
silentflag
,
/* -S: detach tty */
SendStop
,
/* -s: send SIGSTOP */
original_extraoptions
/* options for backend */
)
)
{
ExitPostmaster
(
1
);
return
0
;
}
/*
* Set up signal handlers for the postmaster process.
*/
...
...
@@ -2068,3 +2125,115 @@ SSDataBase(bool startup)
return
(
pid
);
}
static
char
PidFile
[
MAXPGPATH
];
static
void
UnlinkPidFile
(
void
)
{
unlink
(
PidFile
);
}
static
int
SetPidFile
(
pid_t
pid
,
char
*
progname
,
int
port
,
char
*
datadir
,
int
assert
,
int
nbuf
,
char
*
execfile
,
int
debuglvl
,
int
netserver
,
#ifdef USE_SSL
int
securenetserver
,
#endif
int
maxbackends
,
int
reinit
,
int
silent
,
int
sendstop
,
char
*
extraoptions
)
{
int
fd
;
char
optsfile
[
MAXPGPATH
];
char
pidstr
[
32
];
char
opts
[
1024
];
char
buf
[
1024
];
/*
* Creating pid file
*/
sprintf
(
PidFile
,
"%s/%s"
,
datadir
,
PIDFNAME
);
fd
=
open
(
PidFile
,
O_RDWR
|
O_CREAT
|
O_EXCL
,
0600
);
if
(
fd
<
0
)
{
fprintf
(
stderr
,
"Can't create pidfile: %s
\n
"
,
PidFile
);
fprintf
(
stderr
,
"Is another postmaser running?
\n
"
);
return
(
-
1
);
}
sprintf
(
pidstr
,
"%d"
,
pid
);
if
(
write
(
fd
,
pidstr
,
strlen
(
pidstr
))
!=
strlen
(
pidstr
))
{
fprintf
(
stderr
,
"Write to pid file failed
\n
"
);
close
(
fd
);
unlink
(
PidFile
);
return
(
-
1
);
}
close
(
fd
);
/*
* Creating opts file
*/
sprintf
(
optsfile
,
"%s/%s"
,
datadir
,
OPTSFNAME
);
fd
=
open
(
optsfile
,
O_RDWR
|
O_TRUNC
|
O_CREAT
,
0600
);
if
(
fd
<
0
)
{
fprintf
(
stderr
,
"Can't create optsfile:%s"
,
optsfile
);
unlink
(
PidFile
);
return
(
-
1
);
}
sprintf
(
opts
,
"%s
\n
-p %d
\n
-D %s
\n
"
,
progname
,
port
,
datadir
);
if
(
assert
)
{
sprintf
(
buf
,
"-A %d
\n
"
,
assert
);
strcat
(
opts
,
buf
);
}
sprintf
(
buf
,
"-B %d
\n
-b %s
\n
"
,
nbuf
,
execfile
);
strcat
(
opts
,
buf
);
if
(
debuglvl
)
{
sprintf
(
buf
,
"-d %d
\n
"
,
debuglvl
);
strcat
(
opts
,
buf
);
}
if
(
netserver
)
{
strcat
(
opts
,
"-i
\n
"
);
}
#ifdef USE_SSL
if
(
securenetserver
)
{
strcat
(
opts
,
"-l
\n
"
);
}
#endif
sprintf
(
buf
,
"-N %d
\n
"
,
maxbackends
);
strcat
(
opts
,
buf
);
if
(
!
reinit
)
{
strcat
(
opts
,
"-n
\n
"
);
}
if
(
silent
)
{
strcat
(
opts
,
"-S
\n
"
);
}
if
(
sendstop
)
{
strcat
(
opts
,
"-s
\n
"
);
}
if
(
strlen
(
extraoptions
)
>
0
)
{
strcat
(
opts
,
"-o '"
);
strcat
(
opts
,
extraoptions
);
strcat
(
opts
,
"'"
);
}
if
(
write
(
fd
,
opts
,
strlen
(
opts
))
!=
strlen
(
opts
))
{
perror
(
"Writing to opts file failed"
);
unlink
(
PidFile
);
close
(
fd
);
return
(
-
1
);
}
close
(
fd
);
/*
* register clean up proc
*/
on_proc_exit
(
UnlinkPidFile
,
NULL
);
return
(
0
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录