launchpad.net/~rogpeppe/juju-core/500-errgo-fix@v0.0.0-20140213181702-000000002356/upstart/service.go (about) 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" 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 := path.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 string, env map[string]string) *Conf { 46 svc := NewService(name) 47 logFile := path.Join(logDir, tag+".log") 48 // The machine agent always starts with debug turned on. The logger worker 49 // will update this to the system logging environment as soon as it starts. 50 return &Conf{ 51 Service: *svc, 52 Desc: fmt.Sprintf("juju %s agent", tag), 53 Limit: map[string]string{ 54 "nofile": fmt.Sprintf("%d %d", maxAgentFiles, maxAgentFiles), 55 }, 56 Cmd: path.Join(toolsDir, "jujud") + 57 " machine" + 58 " --data-dir " + utils.ShQuote(dataDir) + 59 " --machine-id " + machineId + 60 " --debug", 61 Out: logFile, 62 Env: env, 63 } 64 }