Permalink
Browse files

More progress on postgresql extension, initial json configuration abi…

…lity.
  • Loading branch information...
1 parent e6d1a49 commit 2169bd585f99f72ede8d1c90091ef925eb1b1850 @wayneeseguin wayneeseguin committed Nov 20, 2011
View
No changes.
View
@@ -0,0 +1,26 @@
+# SM Framework Postgresql Extension
+
+In order to install the latest version of postgresql known to the component do:
+
+ sm postgresql install
+
+Next we configure the sytem to run postgresql:
+
+ sm postgresql configure
+
+To start postgresql:
+
+ sm postgresql start
+
+To stop postgresql:
+
+ sm postgresql stop
+
+To restart postgresql:
+
+ sm postgresql restart
+
+To obtain the status of the postgresql process:
+
+ sm postgresql status
+
View
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-description "Extension for managing ${extension} (${website_url})."
-
-action "edit" "Opens ${extension}.conf for ${package_name} ${package_version}"\
- "in defined EDITOR or vi if undefined.."
-
-show_help usage
-
View
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+user is root || log error "'postgresql configure' may only be run as root."
+
+paths create "/etc/postgresql/" "/var/log/postgresql" "/var/run/postgresql" \
+ "/var/db/postgresql"
+
+json get \
+ string "postgresql/bind" default 0.0.0.0 \
+ string "postgresql/port" default 5432 \
+ string "postgresql/syslog/facility" default "local0" \
+ string "postgresql/databases" default 24 \
+ string "postgresql/max/clients" default 128 \
+ string "postgresql/max/memory" default "128mb" \
+ string "postgresql/max/slow" default 1024 \
+ string "postgresql/append/fsync" default "everysec" \
+ string "postgresql/append/only" default "yes" \
+ string "postgresql/append/file" default "appendonly.aof" \
+ string "postgresql/log/slow" default 10000
+
+template install "postgresql/postgresql.conf" \
+ to "/etc/postgresql/postgresql.conf" \
+ mode 0644 \
+ with \
+ bind "${postgresql_bind}" \
+ port "${postgresql_port}" \
+ syslog_facility "${postgresql_syslog_facility}" \
+ databases "${postgresql_databases}" \
+ max_clients "${postgresql_max_clients}" \
+ max_memory "${postgresql_max_memory}" \
+ max_slow "${postgresql_max_slow}" \
+ append_fsync "${postgresql_append_fsync}" \
+ append_only "${postgresql_append_only}" \
+ append_file "${postgresql_append_file}" \
+ log_slow "${postgresql_log_slow}"
+
+template install "postgresql/init.d" \
+ to "/etc/init.d/postgresql" \
+ mode 0755 \
+ with \
+ service_bin_path "${sm_path}/pkg/active/bin"
+
+template install "postgresql/conf.d" \
+ to "/etc/conf.d/postgresql.conf" \
+ mode 0755 \
+ with \
+ service_bin_path "${sm_path}/pkg/active/bin" \
+ service_pid_file "/var/run/postgresql/postgresql.pid" \
+ service_config_file "/etc/postgresql/postgresql.conf" \
+ service_log_file "/var/log/postgresql/postgresql.log" \
+ service_data_path "${service_data_path}" \
+ port 5432 \
+
+template install "postgresql/monitrc" \
+ to "/etc/monit.d/postgresql.monitrc" \
+ mode 0644 \
+ with \
+ service_bin_path "${sm_path}/pkg/active/bin" \
+ service_pid_file "/var/run/postgresql/postgresql.pid" \
+ service_config_file "/etc/postgresql/postgresql.conf" \
+ service_log_file "/var/log/postgresql/postgresql.log" \
+ start_timeout 30 \
+ port 5432 \
+ bind 127.00.1
+
+monit reload
+
View
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-action "package install" "Installs ${package_name} ${package_version}."
-action "package uninstall" "Installs ${package_name} ${package_version}."
-
-action "service start" "Starts ${extension} service."
-action "service stop" "Stops ${extension} service."
-action "service restart" "Restart ${extension} service."
-action "service status" "Status of the ${extension} service."
-
-action "backup [action]" "configurations."
-action "conf [action]" "Work with ${extension} server configuration file."
-action "[namespace] help" "Display help for namespaces ${extension} {service,package,conf,backup}."
-
-show_help usage
-
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-action "package install" "Installs ${package_name} ${package_version}."
-action "package uninstall" "Installs ${package_name} ${package_version}."
-
-show_help usage
-
View
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+exec su - "${service_user}" -c "$control reload -D '${service_data_path}' -s"
+
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+NIY "replication setup"
+
+#json get \
+# string "postgresql/replication/master" \
+# string "postgresql/replication/slaves"
+
+/etc/init.d/postgresql stop
+
+su - ${service_user} \
+ -c "ssh -o StrictHostKeyChecking=no postgres@${postgresql_replication_master} 'ssh -o StrictHostKeyChecking=no postgres@${hostname} uname'"
+
+files remove /var/db/postgresql/active/wal/*
+
+psql -U ${service_user} -h ${postgresql_replication_master} \
+ -c"select pg_start_backup('`date`');"
+
+su - ${service_user} \
+ -c "touch /var/db/postgresql/active/wal/00000001.history"
+
+su - ${service_user} \
+ -c "rsync -avPz --delete --exclude .svn --exclude recovery.conf --exclude recovery.py --exclude postgresql.conf --exclude pg_log --exclude pg_xlog ${postgresql_replication_master}:/var/db/postgresql/active/data/ /var/db/postgres/active/data/"
+
+find /var/db/postgres/active/data/pg_xlog -type f | xargs rm -f
+
+psql -U ${service_user} -h ${postgresql_replication_master} \
+ -c"select pg_stop_backup();"
+
+/etc/init.d/postgresql start
+
+
+
View
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+exec su - "${service_user}" -c "$control restart -D '${service_data_path}' -s"
+
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-action "service start" "Starts ${extension} service."
-action "service stop" "Stops ${extension} service."
-action "service restart" "Restart ${extension} service."
-action "service status" "Status of the ${extension} service."
-
-show_help usage
-
View
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+exec su - "${service_user}" -c "$control start -D '${service_data_path}' -s"
+
View
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+exec su - "${service_user}" -c "$control start -D '${service_data_path}' -s"
+
Oops, something went wrong.

0 comments on commit 2169bd5

Please sign in to comment.