サーバ起動シェル
あまりにも使い勝手が悪いのでシェルを組んでおく。
要件としては、pg_ctl だけでも postgres 権限で実行出来るようにしたい。
ということで、pg_ctl をpostgres 権限で叩くシェルを書いてみた。
- pg_ctl_postgres
#!/usr/bin/env sh if [ "${1}" != "" ] ; then eval "sudo su postgres -c 'pg_ctl $@'" else eval "pg_ctl --help" fi exit 0
引数が無ければヘルプを表示する仕様。
準備
$ sudo mv pg_ctl_postgres /opt/local/lib/postgresql83/bin/ Password: $ sudo chmod +x /opt/local/lib/postgresql83/bin/pg_ctl_postgres $ sudo ln -s /opt/local/lib/postgresql83/bin/pg_ctl_postgres /opt/local/bin
開始
$ ./pg_ctl_postgres -D /opt/local/var/db/postgresql83/defaultdb start Password: server starting LOG: database system was shut down at 2009-01-16 22:27:15 JST LOG: autovacuum launcher started LOG: database system is ready to accept connections
停止
$ ./pg_ctl_postgres -D /opt/local/var/db/postgresql83/defaultdb stop Password: waiting for server to shut down....LOG: received smart shutdown request LOG: autovacuum launcher shutting down LOG: shutting down LOG: database system is shut down done server stopped