Commit be781bdb by Torkel Ödegaard

Tried postgres

parent a8f915f0
FROM ubuntu
# Add the PostgreSQL PGP key to verify their Debian packages.
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
# Add PostgreSQL's repository. It contains the most recent stable release
# of PostgreSQL, ``9.3``.
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
# Install ``python-software-properties``, ``software-properties-common`` and PostgreSQL 9.3
# There are some warnings (in red) that show up during the build. You can hide
# them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y python-software-properties software-properties-common postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
# Note: The official Debian and Ubuntu images automatically ``apt-get clean``
# after each ``apt-get``
# Run the rest of the commands as the ``postgres`` user created by the ``postgres-9.3`` package when it was ``apt-get installed``
USER postgres
# Create a PostgreSQL role named ``docker`` with ``docker`` as the password and
# then create a database `docker` owned by the ``docker`` role.
# Note: here we use ``&&\`` to run commands one after the other - the ``\``
# allows the RUN command to span multiple lines.
RUN /etc/init.d/postgresql start &&\
psql --command "CREATE USER grafana WITH SUPERUSER PASSWORD 'grafana';" &&\
createdb -O grafana grafana
# Adjust PostgreSQL configuration so that remote connections to the
# database are possible.
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf
# And add ``listen_addresses`` to ``/etc/postgresql/9.3/main/postgresql.conf``
RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf
# Expose the PostgreSQL port
EXPOSE 5432
# Add VOLUMEs to allow backup of config, logs and databases
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
# Set the default command to run when starting the container
CMD ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/var/lib/postgresql/9.3/main", "-c", "config_file=/etc/postgresql/9.3/main/postgresql.conf"]
......@@ -65,7 +65,18 @@ ssl_mode = disable
; For "sqlite3" only
path = data/grafana.db
; [database]
; ; Either "mysql", "postgres" or "sqlite3", it's your choice
; type = postgres
; host = 127.0.0.1:5432
; name = grafana
; user = grafana
; password = grafana
; ; For "postgres" only, either "disable", "require" or "verify-full"
; ssl_mode = disable
; ; For "sqlite3" only
; path = data/grafana.db
;
[log]
root_path =
; Either "console", "file", "conn", "smtp" or "database", default is "console"
......
go get code.google.com/p/goprotobuf/{proto,protoc-gen-go}
......@@ -76,7 +76,7 @@ func (ctx *Context) JsonApiErr(status int, message string, err error) {
resp["message"] = message
}
ctx.HTML(status, "index")
ctx.JSON(status, resp)
}
func (ctx *Context) JsonBody(model interface{}) bool {
......
......@@ -40,12 +40,12 @@ func AddCollaborator(c *middleware.Context) {
accountToAdd, err := models.GetAccountByLogin(model.Email)
if err != nil {
c.JSON(404, utils.DynMap{"message": "Collaborator not found"})
c.JsonApiErr(404, "Collaborator not found", nil)
return
}
if accountToAdd.Id == c.UserAccount.Id {
c.JSON(400, utils.DynMap{"message": "Cannot add yourself as collaborator"})
c.JsonApiErr(400, "Cannot add yourself as collaborator", nil)
return
}
......@@ -53,7 +53,7 @@ func AddCollaborator(c *middleware.Context) {
err = models.AddCollaborator(collaborator)
if err != nil {
c.JSON(400, utils.DynMap{"message": err.Error()})
c.JsonApiErr(500, "Could not add collaborator", err)
return
}
......
package server
import (
"github.com/torkelo/grafana-pro/pkg/api"
"github.com/torkelo/grafana-pro/pkg/configuration"
"github.com/torkelo/grafana-pro/pkg/stores"
)
type Server struct {
HttpServer *api.HttpServer
Store stores.Store
}
func NewServer(cfg *configuration.Cfg) (*Server, error) {
store := stores.New()
httpServer := api.NewHttpServer(cfg, store)
return &Server{
HttpServer: httpServer,
Store: store,
}, nil
}
func (self *Server) ListenAndServe() error {
self.HttpServer.ListenAndServe()
return nil
}
......@@ -50,7 +50,7 @@ func LoadModelsConfig() {
DbCfg.Name = setting.Cfg.MustValue("database", "name")
DbCfg.User = setting.Cfg.MustValue("database", "user")
if len(DbCfg.Pwd) == 0 {
DbCfg.Pwd = setting.Cfg.MustValue("database", "passwd")
DbCfg.Pwd = setting.Cfg.MustValue("database", "password")
}
DbCfg.SslMode = setting.Cfg.MustValue("database", "ssl_mode")
DbCfg.Path = setting.Cfg.MustValue("database", "path", "data/grafana.db")
......
......@@ -61,9 +61,9 @@ func GetAccountByLogin(emailOrLogin string) (*models.Account, error) {
func GetCollaboratorsForAccount(accountId int64) ([]*models.CollaboratorInfo, error) {
collaborators := make([]*models.CollaboratorInfo, 0)
sess := x.Table("Collaborator")
sess.Join("INNER", "Account", "Account.id=Collaborator.account_Id")
sess.Where("Collaborator.for_account_id=?", accountId)
sess := x.Table("collaborator")
sess.Join("INNER", "account", "account.id=collaborator.account_Id")
sess.Where("collaborator.for_account_id=?", accountId)
err := sess.Find(&collaborators)
return collaborators, err
......@@ -91,9 +91,9 @@ func AddCollaborator(collaborator *models.Collaborator) error {
func GetOtherAccountsFor(accountId int64) ([]*models.OtherAccount, error) {
collaborators := make([]*models.OtherAccount, 0)
sess := x.Table("Collaborator")
sess.Join("INNER", "Account", "Account.id=Collaborator.account_Id")
sess.Where("Collaborator.account_id=?", accountId)
sess := x.Table("collaborator")
sess.Join("INNER", "account", "account.id=collaborator.account_Id")
sess.Where("account_id=?", accountId)
err := sess.Find(&collaborators)
return collaborators, err
}
docker kill rethinkdb
docker rm rethinkdb
docker build -t gf-pro-image .
docker run -d -p 8180:8080 -p 28015:28015 -p 29015:29015 \
--name rethinkdb \
-v /var/docker/grafana-pro-rethinkdb:/data \
dockerfile/rethinkdb
docker kill gf-pro
docker rm gf-pro
docker run -d --name="gf-pro" \
-p 127.0.0.1:5432:5432 \
-v /var/docker/grafana-pro/postgresql:/var/lib/postgres \
gf-pro-image
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment