/
mongodb.upstart.erb
76 lines (61 loc) · 1.83 KB
/
mongodb.upstart.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# THIS FILE HAS BEEN GENERATED BY CHEF
# ANY MANUAL MODIFICATIONS WILL BE OVERWRITTEN
# mongodb.upstart.conf
<%
@config = node[:mongodb][@server_type]
@binary = @server_type == :mongos ? 'mongos' : 'mongod'
%>
pre-start script
<% if @config[:dbpath] %>
mkdir -p <%= @config[:dbpath] %>
chown -R mongodb:mongodb <%= @config[:dbpath] %>
<% end %>
mkdir -p <%= File.dirname(@config[:logpath]) %>
end script
start on runlevel [2345]
stop on runlevel [06]
script
ENABLE_MONGODB="yes"
DAEMON=/usr/bin/<%= @binary %>
NAME=<%= @server_type %>
# Default defaults. Can be overridden by the /etc/default/$NAME
CONF=<%= @config[:config] %>
PIDFILE=<%= @config[:pidfile] %>
<% case @server_type; when 'config_server' %>
CONFIGSVR=--configsvr
<% when 'mongos' %>
CONFIGDB="--configdb <%= @configdb_server_list %>"
<% else %>
REPLSET=<%= @config[:replSet] %>
SHARDSVR=<%= @config[:shardsvr] %>
<% end %>
<% unless @server_type == 'mongos' %>
REST=<%= @config[:rest] %>
SYNCDELAY="--syncdelay <%= @config[:syncdelay] %>"
<% end %>
if [ -f /etc/default/$NAME ]; then . /etc/default/$NAME; fi
# Check for daemon bin
if test ! -x $DAEMON; then
echo "Could not find $DAEMON"
exit 0
fi
# This will enable the REST Interface for MongoDB if told so
if test "x$REST" = "xtrue"; then
REST=--rest
else
REST=
fi
# This will make the server part of a replica set
if test "x$REPLSET" = "x"; then
REPLSET=
else
REPLSET="--replSet $REPLSET"
fi
# This will make the server participate in sharding
if test "x$SHARDSVR" = "xtrue"; then
SHARDSVR=--shardsvr
else
SHARDSVR=
fi
if [ "x$ENABLE_MONGODB" = "xyes" ]; then exec start-stop-daemon --start --quiet --chuid mongodb --exec $DAEMON -- $REST $REPLSET $SHARDSVR $CONFIGSVR $SYNCDELAY $CONFIGDB --config $CONF; fi
end script