Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaf96aa9

Browse files
committed
I wanted to submit some changes to the bundled postgres startup
script for Mac OS X. I added calls to utilize the bundled apacherotatelogs script in the DB startup for log rotation. Also modifiedstartup parameters file to allow using the "SystemStarter" utility tostart/stop/restart postgres with a rotating log file.The script credits David Wheeler, 2002. I wrote him a message aboutthe changes an he suggested I post them here. I explain some of thechanges below.Not sure how to submit the changes. I have 3 files, "PostgreSQL"script, "StartupParameters.plist" file, "pg_startupscript.diff" file.The diff file was run against the original "PostgreSQL" script file.I'll try attaching them to this message. If they get filtered I canresend if needed.Thanks.Ray A.------------------------------------1) Changed the "Provides" parameter in StartupParameters.plist to"PostgreSQL" from "postgres database" simply for ease of typing. Itseems that the SystemStarter utility uses the "Provides" value if youwant to control the script. This way I did not have to enclose it inquotes on commandline. The modified StartupParameters.plist is now anXML document also.2) For the startup script I added 2 user modifiable variables:# do you want to rotate the log files, 1=true 0=falseROTATELOGS=1# logfile rotate in secondsROTATESEC="604800"I also added a non modifiable variable:# The apache log rotation utilityLOGUTIL="/usr/sbin/rotatelogs"I modified the StartService and RestartService functions to executethe new commands if the user wants log rotation.Ray Aspeitia
1 parente0bed41 commitaf96aa9

File tree

2 files changed

+71
-23
lines changed

2 files changed

+71
-23
lines changed

‎contrib/start-scripts/PostgreSQL.darwin

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
##
4-
#PotgreSQL RDBMS Server
4+
#PostgreSQL RDBMS Server
55
##
66

77
# PostgreSQL boot time startup script for Darwin/Mac OS X. To install, change
@@ -12,7 +12,7 @@
1212
# directory it is in. So you'll end up with these two files:
1313
#
1414
# /Library/StartupItems/PostgreSQL/PostgreSQL
15-
# /Library/StartupItems/PostgreSQLStartupParameters.plist
15+
# /Library/StartupItems/PostgreSQL/StartupParameters.plist
1616
#
1717
# Next, add this line to the /etc/hostconfig file:
1818
#
@@ -30,21 +30,36 @@
3030
#
3131
# Created by David Wheeler, 2002.
3232

33+
# modified by Ray Aspeitia 12-03-2003 :
34+
# added log rotation script to db startup
35+
# modified StartupParameters.plist "Provides" parameter to make it easier to
36+
# start and stop with the SystemStarter utitlity
37+
38+
# use the below command in order to correctly start/stop/restart PG with log rotation script:
39+
# SystemStarter [start|stop|restart] PostgreSQL
40+
3341
################################################################################
3442
## EDIT FROM HERE
3543
################################################################################
3644

3745
# Installation prefix
38-
prefix=/usr/local/pgsql
46+
prefix="/usr/local/pgsql"
3947

4048
# Data directory
4149
PGDATA="/usr/local/pgsql/data"
4250

4351
# Who to run pg_ctl as, should be "postgres".
44-
PGUSER=postgres
52+
PGUSER="postgres"
53+
54+
# the logfile path and name (NEEDS to be writeable by PGUSER)
55+
PGLOG="${PGDATA}/logs/logfile"
56+
57+
# do you want to rotate the log files, 1=true 0=false
58+
ROTATELOGS=1
59+
60+
# logfile rotate in seconds
61+
ROTATESEC="604800"
4562

46-
# Where to keep a log file
47-
PGLOG="$PGDATA/serverlog"
4863

4964
################################################################################
5065
## STOP EDITING HERE
@@ -56,12 +71,19 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
5671
# What to use to start up the postmaster
5772
DAEMON="$prefix/bin/pg_ctl"
5873

74+
# The apache log rotation utility
75+
LOGUTIL="/usr/sbin/rotatelogs"
76+
5977
. /etc/rc.common
6078

6179
StartService () {
6280
if ["${POSTGRESQLSERVER:=-NO-}"="-YES-" ];then
63-
ConsoleMessage"Starting PostgreSQL database server"
64-
sudo -u$PGUSER$DAEMON start -D"$PGDATA" -s -l$PGLOG
81+
ConsoleMessage"Starting PostgreSQL database server"
82+
if ["${ROTATELOGS}"="1" ];then
83+
sudo -u$PGUSER sh -c"${DAEMON} start -D${PGDATA} -s |${LOGUTIL}${PGLOG}${ROTATESEC} &"
84+
else
85+
sudo -u$PGUSER$DAEMON start -D"$PGDATA" -s -l$PGLOG
86+
fi
6587
fi
6688
}
6789

@@ -73,9 +95,15 @@ StopService () {
7395
RestartService () {
7496
if ["${POSTGRESQLSERVER:=-NO-}"="-YES-" ];then
7597
ConsoleMessage"Restarting PostgreSQL database server"
76-
sudo -u$PGUSER$DAEMON restart -D"$PGDATA" -s -m fast
98+
if ["${ROTATELOGS}"="1" ];then
99+
# StopService
100+
# StartService
101+
sudo -u$PGUSER sh -c"${DAEMON} restart -D${PGDATA} -s -m fast |${LOGUTIL}${PGLOG}${ROTATESEC} &"
102+
else
103+
sudo -u$PGUSER$DAEMON restart -D"$PGDATA" -s -m fast
104+
fi
77105
else
78-
StopService
106+
StopService
79107
fi
80108
}
81109

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
1-
{
2-
Description = "PostgreSQL Database Server";
3-
Provides = ("postgres database");
4-
Requires = ("Disks", "Resolver");
5-
Uses = ("NFS", "Network Time");
6-
OrderPreference = "None";
7-
Messages =
8-
{
9-
start = "Starting PostgreSQL database server";
10-
stop = "Stopping PostgreSQL database server";
11-
restart = "Restarting PostgreSQL database server";
12-
};
13-
}
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPEplist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plistversion="1.0">
4+
<dict>
5+
<key>Description</key>
6+
<string>PostgreSQL Database Server</string>
7+
<key>Messages</key>
8+
<dict>
9+
<key>start</key>
10+
<string>Starting PostgreSQL database server</string>
11+
<key>stop</key>
12+
<string>Stopping PostgreSQL database server</string>
13+
<key>restart</key>
14+
<string>Restarting PostgreSQL database server</string>
15+
</dict>
16+
<key>OrderPreference</key>
17+
<string>Late</string>
18+
<key>Provides</key>
19+
<array>
20+
<string>PostgreSQL</string>
21+
</array>
22+
<key>Requires</key>
23+
<array>
24+
<string>Disks</string>
25+
<string>Resolver</string>
26+
</array>
27+
<key>Uses</key>
28+
<array>
29+
<string>NFS</string>
30+
<string>NetworkTime</string>
31+
</array>
32+
</dict>
33+
</plist>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp