blob: e4b5d40c950e809270c6f014a3b8e194392f66eb [file] [log] [blame]
Attila Fazekasece6a332012-11-29 14:19:41 +01001# lib/swift
Dean Troyer6d04fd72012-12-21 11:03:37 -06002# Functions to control the configuration and operation of the **Swift** service
Attila Fazekasece6a332012-11-29 14:19:41 +01003
4# Dependencies:
5# ``functions`` file
6# ``DEST``, ``SCREEN_NAME``, `SWIFT_HASH` must be defined
Attila Fazekas91b8d132013-01-06 22:40:09 +01007# ``STACK_USER`` must be defined
Attila Fazekasece6a332012-11-29 14:19:41 +01008# ``SWIFT_DATA_DIR`` or ``DATA_DIR`` must be defined
9# ``lib/keystone`` file
10# ``stack.sh`` calls the entry points in this order:
11#
12# install_swift
13# configure_swift
14# init_swift
15# start_swift
16# stop_swift
17# cleanup_swift
18
19# Save trace setting
20XTRACE=$(set +o | grep xtrace)
21set +o xtrace
22
23
24# Defaults
25# --------
26
Attila Fazekasece6a332012-11-29 14:19:41 +010027# Set up default directories
Attila Fazekasece6a332012-11-29 14:19:41 +010028SWIFT_DIR=$DEST/swift
29SWIFTCLIENT_DIR=$DEST/python-swiftclient
Dean Troyer64ab7742012-12-28 15:38:28 -060030SWIFT_AUTH_CACHE_DIR=${SWIFT_AUTH_CACHE_DIR:-/var/cache/swift}
Attila Fazekasece6a332012-11-29 14:19:41 +010031
32# TODO: add logging to different location.
33
34# Set ``SWIFT_DATA_DIR`` to the location of swift drives and objects.
35# Default is the common DevStack data directory.
36SWIFT_DATA_DIR=${SWIFT_DATA_DIR:-${DATA_DIR}/swift}
37
Dean Troyer6ec72fa2013-03-13 11:44:53 -050038# Set ``SWIFT_CONF_DIR`` to the location of the configuration files.
Attila Fazekasece6a332012-11-29 14:19:41 +010039# Default is ``/etc/swift``.
Dean Troyer6ec72fa2013-03-13 11:44:53 -050040# TODO(dtroyer): remove SWIFT_CONFIG_DIR after cutting stable/grizzly
41SWIFT_CONF_DIR=${SWIFT_CONF_DIR:-${SWIFT_CONFIG_DIR:-/etc/swift}}
Attila Fazekasece6a332012-11-29 14:19:41 +010042
43# DevStack will create a loop-back disk formatted as XFS to store the
Kevin Lydad66c9652013-01-09 13:39:57 +000044# swift data. Set ``SWIFT_LOOPBACK_DISK_SIZE`` to the disk size in
45# kilobytes.
Attila Fazekasece6a332012-11-29 14:19:41 +010046# Default is 1 gigabyte.
47SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000}
48
49# The ring uses a configurable number of bits from a path’s MD5 hash as
50# a partition index that designates a device. The number of bits kept
51# from the hash is known as the partition power, and 2 to the partition
52# power indicates the partition count. Partitioning the full MD5 hash
53# ring allows other parts of the cluster to work in batches of items at
54# once which ends up either more efficient or at least less complex than
55# working with each item separately or the entire cluster all at once.
56# By default we define 9 for the partition count (which mean 512).
57SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9}
58
59# Set ``SWIFT_REPLICAS`` to configure how many replicas are to be
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +010060# configured for your Swift cluster. By default we are configuring
61# only one replica since this is way less CPU and memory intensive. If
62# you are planning to test swift replication you may want to set this
63# up to 3.
64SWIFT_REPLICAS=${SWIFT_REPLICAS:-1}
Attila Fazekasece6a332012-11-29 14:19:41 +010065SWIFT_REPLICAS_SEQ=$(seq ${SWIFT_REPLICAS})
66
67# Set ``OBJECT_PORT_BASE``, ``CONTAINER_PORT_BASE``, ``ACCOUNT_PORT_BASE``
68# Port bases used in port number calclution for the service "nodes"
69# The specified port number will be used, the additinal ports calculated by
70# base_port + node_num * 10
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +010071OBJECT_PORT_BASE=6013
Attila Fazekasece6a332012-11-29 14:19:41 +010072CONTAINER_PORT_BASE=6011
73ACCOUNT_PORT_BASE=6012
74
Dean Troyer6d04fd72012-12-21 11:03:37 -060075
Attila Fazekasece6a332012-11-29 14:19:41 +010076# Entry Points
77# ------------
78
79# cleanup_swift() - Remove residual data files
80function cleanup_swift() {
Dean Troyer6ec72fa2013-03-13 11:44:53 -050081 rm -f ${SWIFT_CONF_DIR}{*.builder,*.ring.gz,backups/*.builder,backups/*.ring.gz}
Attila Fazekasece6a332012-11-29 14:19:41 +010082 if egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then
83 sudo umount ${SWIFT_DATA_DIR}/drives/sdb1
84 fi
85 if [[ -e ${SWIFT_DATA_DIR}/drives/images/swift.img ]]; then
86 rm ${SWIFT_DATA_DIR}/drives/images/swift.img
87 fi
88}
89
90# configure_swift() - Set config files, create data dirs and loop image
91function configure_swift() {
92 local swift_auth_server
93 local node_number
94 local swift_node_config
95 local swift_log_dir
96
97 setup_develop $SWIFT_DIR
98
99 # Make sure to kill all swift processes first
Chmouel Boudjnahad8b2762013-01-10 15:40:01 +0100100 swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true
Attila Fazekasece6a332012-11-29 14:19:41 +0100101
102 # First do a bit of setup by creating the directories and
103 # changing the permissions so we can run it as our user.
104
105 USER_GROUP=$(id -g)
Chmouel Boudjnahad8b2762013-01-10 15:40:01 +0100106 sudo mkdir -p ${SWIFT_DATA_DIR}/{drives,cache,run,logs}
Attila Fazekasece6a332012-11-29 14:19:41 +0100107 sudo chown -R $USER:${USER_GROUP} ${SWIFT_DATA_DIR}
108
109 # Create a loopback disk and format it to XFS.
110 if [[ -e ${SWIFT_DATA_DIR}/drives/images/swift.img ]]; then
111 if egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then
112 sudo umount ${SWIFT_DATA_DIR}/drives/sdb1
Chmouel Boudjnah43eb0b32013-01-12 20:10:34 +0000113 sudo rm -f ${SWIFT_DATA_DIR}/drives/images/swift.img
Attila Fazekasece6a332012-11-29 14:19:41 +0100114 fi
Attila Fazekasece6a332012-11-29 14:19:41 +0100115 fi
116
Chmouel Boudjnah43eb0b32013-01-12 20:10:34 +0000117 mkdir -p ${SWIFT_DATA_DIR}/drives/images
118 sudo touch ${SWIFT_DATA_DIR}/drives/images/swift.img
119 sudo chown $USER: ${SWIFT_DATA_DIR}/drives/images/swift.img
120
121 dd if=/dev/zero of=${SWIFT_DATA_DIR}/drives/images/swift.img \
122 bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE}
123
Attila Fazekasece6a332012-11-29 14:19:41 +0100124 # Make a fresh XFS filesystem
125 mkfs.xfs -f -i size=1024 ${SWIFT_DATA_DIR}/drives/images/swift.img
126
127 # Mount the disk with mount options to make it as efficient as possible
128 mkdir -p ${SWIFT_DATA_DIR}/drives/sdb1
129 if ! egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then
130 sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 \
131 ${SWIFT_DATA_DIR}/drives/images/swift.img ${SWIFT_DATA_DIR}/drives/sdb1
132 fi
133
134 # Create a link to the above mount and
135 # create all of the directories needed to emulate a few different servers
136 for node_number in ${SWIFT_REPLICAS_SEQ}; do
137 sudo ln -sf ${SWIFT_DATA_DIR}/drives/sdb1/$node_number ${SWIFT_DATA_DIR}/$node_number;
138 drive=${SWIFT_DATA_DIR}/drives/sdb1/${node_number}
139 node=${SWIFT_DATA_DIR}/${node_number}/node
140 node_device=${node}/sdb1
141 [[ -d $node ]] && continue
142 [[ -d $drive ]] && continue
143 sudo install -o ${USER} -g $USER_GROUP -d $drive
144 sudo install -o ${USER} -g $USER_GROUP -d $node_device
145 sudo chown -R $USER: ${node}
146 done
147
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500148 sudo mkdir -p ${SWIFT_CONF_DIR}/{object,container,account}-server
149 sudo chown -R $USER: ${SWIFT_CONF_DIR}
Attila Fazekasece6a332012-11-29 14:19:41 +0100150
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500151 if [[ "$SWIFT_CONF_DIR" != "/etc/swift" ]]; then
Attila Fazekasece6a332012-11-29 14:19:41 +0100152 # Some swift tools are hard-coded to use ``/etc/swift`` and are apparently not going to be fixed.
153 # Create a symlink if the config dir is moved
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500154 sudo ln -sf ${SWIFT_CONF_DIR} /etc/swift
Attila Fazekasece6a332012-11-29 14:19:41 +0100155 fi
156
157 # Swift use rsync to synchronize between all the different
158 # partitions (which make more sense when you have a multi-node
159 # setup) we configure it with our version of rsync.
160 sed -e "
161 s/%GROUP%/${USER_GROUP}/;
162 s/%USER%/$USER/;
163 s,%SWIFT_DATA_DIR%,$SWIFT_DATA_DIR,;
164 " $FILES/swift/rsyncd.conf | sudo tee /etc/rsyncd.conf
165 # rsyncd.conf just prepared for 4 nodes
Vincent Untzc18b9652012-12-04 12:36:34 +0100166 if is_ubuntu; then
Attila Fazekasece6a332012-11-29 14:19:41 +0100167 sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync
168 else
169 sudo sed -i '/disable *= *yes/ { s/yes/no/ }' /etc/xinetd.d/rsync
170 fi
171
172 if is_service_enabled swift3;then
173 swift_auth_server="s3token "
174 fi
175
176 # By default Swift will be installed with the tempauth middleware
177 # which has some default username and password if you have
178 # configured keystone it will checkout the directory.
179 if is_service_enabled key; then
180 swift_auth_server+="authtoken keystoneauth"
181 else
182 swift_auth_server=tempauth
183 fi
184
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500185 SWIFT_CONFIG_PROXY_SERVER=${SWIFT_CONF_DIR}/proxy-server.conf
Attila Fazekasece6a332012-11-29 14:19:41 +0100186 cp ${SWIFT_DIR}/etc/proxy-server.conf-sample ${SWIFT_CONFIG_PROXY_SERVER}
187
188 iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user
189 iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user ${USER}
190
191 iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500192 iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir ${SWIFT_CONF_DIR}
Attila Fazekasece6a332012-11-29 14:19:41 +0100193
194 iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers
195 iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers 1
196
197 iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT log_level
198 iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT log_level DEBUG
199
200 iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port
201 iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port ${SWIFT_DEFAULT_BIND_PORT:-8080}
202
203 # Only enable Swift3 if we have it enabled in ENABLED_SERVICES
204 is_service_enabled swift3 && swift3=swift3 || swift3=""
205
206 iniset ${SWIFT_CONFIG_PROXY_SERVER} pipeline:main pipeline "catch_errors healthcheck cache ratelimit ${swift3} ${swift_auth_server} proxy-logging proxy-server"
207
208 iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server account_autocreate true
209
210 # Configure Keystone
211 sed -i '/^# \[filter:authtoken\]/,/^# \[filter:keystoneauth\]$/ s/^#[ \t]*//' ${SWIFT_CONFIG_PROXY_SERVER}
212 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken auth_host $KEYSTONE_AUTH_HOST
213 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken auth_port $KEYSTONE_AUTH_PORT
214 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL
215 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/
216 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken admin_tenant_name $SERVICE_TENANT_NAME
217 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken admin_user swift
218 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken admin_password $SERVICE_PASSWORD
Dean Troyer64ab7742012-12-28 15:38:28 -0600219 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken signing_dir $SWIFT_AUTH_CACHE_DIR
Attila Fazekasece6a332012-11-29 14:19:41 +0100220
221 iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth use
222 iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth operator_roles
223 iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth operator_roles "Member, admin"
224
225 if is_service_enabled swift3; then
226 cat <<EOF >>${SWIFT_CONFIG_PROXY_SERVER}
227# NOTE(chmou): s3token middleware is not updated yet to use only
228# username and password.
229[filter:s3token]
230paste.filter_factory = keystone.middleware.s3_token:filter_factory
231auth_port = ${KEYSTONE_AUTH_PORT}
232auth_host = ${KEYSTONE_AUTH_HOST}
233auth_protocol = ${KEYSTONE_AUTH_PROTOCOL}
234auth_token = ${SERVICE_TOKEN}
235admin_token = ${SERVICE_TOKEN}
236
237[filter:swift3]
238use = egg:swift3#swift3
239EOF
240 fi
241
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500242 cp ${SWIFT_DIR}/etc/swift.conf-sample ${SWIFT_CONF_DIR}/swift.conf
243 iniset ${SWIFT_CONF_DIR}/swift.conf swift-hash swift_hash_path_suffix ${SWIFT_HASH}
Attila Fazekasece6a332012-11-29 14:19:41 +0100244
245 # This function generates an object/account/proxy configuration
246 # emulating 4 nodes on different ports
247 function generate_swift_config() {
248 local swift_node_config=$1
249 local node_id=$2
250 local bind_port=$3
251
252 log_facility=$[ node_id - 1 ]
253 node_path=${SWIFT_DATA_DIR}/${node_number}
254
255 iniuncomment ${swift_node_config} DEFAULT user
256 iniset ${swift_node_config} DEFAULT user ${USER}
257
258 iniuncomment ${swift_node_config} DEFAULT bind_port
259 iniset ${swift_node_config} DEFAULT bind_port ${bind_port}
260
261 iniuncomment ${swift_node_config} DEFAULT swift_dir
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500262 iniset ${swift_node_config} DEFAULT swift_dir ${SWIFT_CONF_DIR}
Attila Fazekasece6a332012-11-29 14:19:41 +0100263
264 iniuncomment ${swift_node_config} DEFAULT devices
265 iniset ${swift_node_config} DEFAULT devices ${node_path}
266
267 iniuncomment ${swift_node_config} DEFAULT log_facility
268 iniset ${swift_node_config} DEFAULT log_facility LOG_LOCAL${log_facility}
269
270 iniuncomment ${swift_node_config} DEFAULT mount_check
271 iniset ${swift_node_config} DEFAULT mount_check false
272
273 iniuncomment ${swift_node_config} ${server_type}-replicator vm_test_mode
274 iniset ${swift_node_config} ${server_type}-replicator vm_test_mode yes
275 }
276
277 for node_number in ${SWIFT_REPLICAS_SEQ}; do
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500278 swift_node_config=${SWIFT_CONF_DIR}/object-server/${node_number}.conf
Attila Fazekasece6a332012-11-29 14:19:41 +0100279 cp ${SWIFT_DIR}/etc/object-server.conf-sample ${swift_node_config}
280 generate_swift_config ${swift_node_config} ${node_number} $[OBJECT_PORT_BASE + 10 * (node_number - 1)]
Chmouel Boudjnah8e5d2f02012-12-20 13:11:43 +0000281 iniset ${swift_node_config} filter:recon recon_cache_path ${SWIFT_DATA_DIR}/cache
282 # Using a sed and not iniset/iniuncomment because we want to a global
283 # modification and make sure it works for new sections.
284 sed -i -e "s,#[ ]*recon_cache_path .*,recon_cache_path = ${SWIFT_DATA_DIR}/cache," ${swift_node_config}
Attila Fazekasece6a332012-11-29 14:19:41 +0100285
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500286 swift_node_config=${SWIFT_CONF_DIR}/container-server/${node_number}.conf
Attila Fazekasece6a332012-11-29 14:19:41 +0100287 cp ${SWIFT_DIR}/etc/container-server.conf-sample ${swift_node_config}
288 generate_swift_config ${swift_node_config} ${node_number} $[CONTAINER_PORT_BASE + 10 * (node_number - 1)]
Attila Fazekas83e10952012-11-30 23:28:07 +0100289 iniuncomment ${swift_node_config} app:container-server allow_versions
290 iniset ${swift_node_config} app:container-server allow_versions "true"
Chmouel Boudjnah8e5d2f02012-12-20 13:11:43 +0000291 sed -i -e "s,#[ ]*recon_cache_path .*,recon_cache_path = ${SWIFT_DATA_DIR}/cache," ${swift_node_config}
Attila Fazekasece6a332012-11-29 14:19:41 +0100292
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500293 swift_node_config=${SWIFT_CONF_DIR}/account-server/${node_number}.conf
Attila Fazekasece6a332012-11-29 14:19:41 +0100294 cp ${SWIFT_DIR}/etc/account-server.conf-sample ${swift_node_config}
295 generate_swift_config ${swift_node_config} ${node_number} $[ACCOUNT_PORT_BASE + 10 * (node_number - 1)]
Chmouel Boudjnah8e5d2f02012-12-20 13:11:43 +0000296 sed -i -e "s,#[ ]*recon_cache_path .*,recon_cache_path = ${SWIFT_DATA_DIR}/cache," ${swift_node_config}
Attila Fazekasece6a332012-11-29 14:19:41 +0100297 done
298
299 swift_log_dir=${SWIFT_DATA_DIR}/logs
300 rm -rf ${swift_log_dir}
301 mkdir -p ${swift_log_dir}/hourly
302 sudo chown -R $USER:adm ${swift_log_dir}
303 sed "s,%SWIFT_LOGDIR%,${swift_log_dir}," $FILES/swift/rsyslog.conf | sudo \
304 tee /etc/rsyslog.d/10-swift.conf
Attila Fazekasece6a332012-11-29 14:19:41 +0100305}
306
307# configure_swiftclient() - Set config files, create data dirs, etc
308function configure_swiftclient() {
309 setup_develop $SWIFTCLIENT_DIR
310}
311
312# init_swift() - Initialize rings
313function init_swift() {
314 local node_number
315 # Make sure to kill all swift processes first
Chmouel Boudjnahad8b2762013-01-10 15:40:01 +0100316 swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true
Attila Fazekasece6a332012-11-29 14:19:41 +0100317
318 # This is where we create three different rings for swift with
319 # different object servers binding on different ports.
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500320 pushd ${SWIFT_CONF_DIR} >/dev/null && {
Attila Fazekasece6a332012-11-29 14:19:41 +0100321
322 rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
323
324 swift-ring-builder object.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
325 swift-ring-builder container.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
326 swift-ring-builder account.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1
327
328 for node_number in ${SWIFT_REPLICAS_SEQ}; do
329 swift-ring-builder object.builder add z${node_number}-127.0.0.1:$[OBJECT_PORT_BASE + 10 * (node_number - 1)]/sdb1 1
330 swift-ring-builder container.builder add z${node_number}-127.0.0.1:$[CONTAINER_PORT_BASE + 10 * (node_number - 1)]/sdb1 1
331 swift-ring-builder account.builder add z${node_number}-127.0.0.1:$[ACCOUNT_PORT_BASE + 10 * (node_number - 1)]/sdb1 1
332 done
333 swift-ring-builder object.builder rebalance
334 swift-ring-builder container.builder rebalance
335 swift-ring-builder account.builder rebalance
336 } && popd >/dev/null
337
Dean Troyer64ab7742012-12-28 15:38:28 -0600338 # Create cache dir
339 sudo mkdir -p $SWIFT_AUTH_CACHE_DIR
Attila Fazekas91b8d132013-01-06 22:40:09 +0100340 sudo chown $STACK_USER $SWIFT_AUTH_CACHE_DIR
Dean Troyer64ab7742012-12-28 15:38:28 -0600341 rm -f $SWIFT_AUTH_CACHE_DIR/*
Attila Fazekasece6a332012-11-29 14:19:41 +0100342}
343
344function install_swift() {
345 git_clone $SWIFT_REPO $SWIFT_DIR $SWIFT_BRANCH
346}
347
348function install_swiftclient() {
349 git_clone $SWIFTCLIENT_REPO $SWIFTCLIENT_DIR $SWIFTCLIENT_BRANCH
350}
351
352
353# start_swift() - Start running processes, including screen
354function start_swift() {
355 # (re)start rsyslog
356 restart_service rsyslog
Chmouel Boudjnah8ecbb382013-03-12 12:15:17 +0100357 # (re)start memcached to make sure we have a clean memcache.
358 restart_service memcached
359
Attila Fazekasece6a332012-11-29 14:19:41 +0100360 # Start rsync
Vincent Untzc18b9652012-12-04 12:36:34 +0100361 if is_ubuntu; then
Attila Fazekasece6a332012-11-29 14:19:41 +0100362 sudo /etc/init.d/rsync restart || :
363 else
364 sudo systemctl start xinetd.service
365 fi
366
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100367 # By default with only one replica we are launching the proxy,
368 # container, account and object server in screen in foreground and
369 # other services in background. If we have SWIFT_REPLICAS set to something
370 # greater than one we first spawn all the swift services then kill the proxy
371 # service so we can run it in foreground in screen. ``swift-init ...
372 # {stop|restart}`` exits with '1' if no servers are running, ignore it just
373 # in case
Chmouel Boudjnahad8b2762013-01-10 15:40:01 +0100374 swift-init --run-dir=${SWIFT_DATA_DIR}/run all restart || true
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500375 if [[ ${SWIFT_REPLICAS} == 1 ]]; then
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100376 todo="object container account"
377 fi
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500378 for type in proxy ${todo}; do
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100379 swift-init --run-dir=${SWIFT_DATA_DIR}/run ${type} stop || true
380 done
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500381 screen_it s-proxy "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONF_DIR}/proxy-server.conf -v"
382 if [[ ${SWIFT_REPLICAS} == 1 ]]; then
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100383 for type in object container account;do
Dean Troyer6ec72fa2013-03-13 11:44:53 -0500384 screen_it s-${type} "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-${type}-server ${SWIFT_CONF_DIR}/${type}-server/1.conf -v"
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100385 done
386 fi
Attila Fazekasece6a332012-11-29 14:19:41 +0100387}
388
389# stop_swift() - Stop running processes (non-screen)
390function stop_swift() {
391 # screen normally killed by unstack.sh
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100392 if type -p swift-init >/dev/null;then
393 swift-init --run-dir=${SWIFT_DATA_DIR}/run all stop || true
394 fi
Attila Fazekasece6a332012-11-29 14:19:41 +0100395}
396
397# Restore xtrace
398$XTRACE