~rogpeppe/juju-core/azure

« back to all changes in this revision

Viewing changes to upstart/service.go

  • Committer: Roger Peppe
  • Date: 2011-12-15 18:54:31 UTC
  • mfrom: (19.5.4 go-juju-ec2-operations)
  • mto: This revision was merged to the branch mainline in revision 30.
  • Revision ID: roger.peppe@canonical.com-20111215185431-tjuxi6bmg1mswcwg
renameĀ environ->environs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2013 Canonical Ltd.
2
 
// Licensed under the AGPLv3, see LICENCE file for details.
3
 
 
4
 
package upstart
5
 
 
6
 
import (
7
 
        "fmt"
8
 
        "path/filepath"
9
 
 
10
 
        "launchpad.net/juju-core/utils"
11
 
)
12
 
 
13
 
const (
14
 
        maxMongoFiles = 65000
15
 
        maxAgentFiles = 20000
16
 
)
17
 
 
18
 
// MongoUpstartService returns the upstart config for the mongo state service.
19
 
func MongoUpstartService(name, dataDir, dbDir string, port int) *Conf {
20
 
        keyFile := filepath.Join(dataDir, "server.pem")
21
 
        svc := NewService(name)
22
 
        return &Conf{
23
 
                Service: *svc,
24
 
                Desc:    "juju state database",
25
 
                Limit: map[string]string{
26
 
                        "nofile": fmt.Sprintf("%d %d", maxMongoFiles, maxMongoFiles),
27
 
                        "nproc":  fmt.Sprintf("%d %d", maxAgentFiles, maxAgentFiles),
28
 
                },
29
 
                Cmd: "/usr/bin/mongod" +
30
 
                        " --auth" +
31
 
                        " --dbpath=" + dbDir +
32
 
                        " --sslOnNormalPorts" +
33
 
                        " --sslPEMKeyFile " + utils.ShQuote(keyFile) +
34
 
                        " --sslPEMKeyPassword ignored" +
35
 
                        " --bind_ip 0.0.0.0" +
36
 
                        " --port " + fmt.Sprint(port) +
37
 
                        " --noprealloc" +
38
 
                        " --syslog" +
39
 
                        " --smallfiles",
40
 
        }
41
 
}
42
 
 
43
 
// MachineAgentUpstartService returns the upstart config for a machine agent
44
 
// based on the tag and machineId passed in.
45
 
func MachineAgentUpstartService(name, toolsDir, dataDir, logDir, tag, machineId, logConfig, providerType string) *Conf {
46
 
        svc := NewService(name)
47
 
        logFile := filepath.Join(logDir, tag+".log")
48
 
        return &Conf{
49
 
                Service: *svc,
50
 
                Desc:    fmt.Sprintf("juju %s agent", tag),
51
 
                Limit: map[string]string{
52
 
                        "nofile": fmt.Sprintf("%d %d", maxAgentFiles, maxAgentFiles),
53
 
                },
54
 
                Cmd: filepath.Join(toolsDir, "jujud") +
55
 
                        " machine" +
56
 
                        " --log-file " + utils.ShQuote(logFile) +
57
 
                        " --data-dir " + utils.ShQuote(dataDir) +
58
 
                        " --machine-id " + machineId +
59
 
                        " " + logConfig,
60
 
                Out: logFile,
61
 
                Env: map[string]string{
62
 
                        "JUJU_PROVIDER_TYPE": providerType,
63
 
                },
64
 
        }
65
 
}