Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
9b079554
Commit
9b079554
authored
13 years ago
by
Dmitry Simonenko
Browse files
Options
Downloads
Patches
Plain Diff
tarantool_expand.sh: proper instances deployment. dry run, debug, status
modes are added.
parent
47a4fa6b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmake/rpm_post_install.sh
+1
-1
1 addition, 1 deletion
cmake/rpm_post_install.sh
extra/CMakeLists.txt
+1
-1
1 addition, 1 deletion
extra/CMakeLists.txt
extra/tarantool_expand.sh
+71
-40
71 additions, 40 deletions
extra/tarantool_expand.sh
with
73 additions
and
42 deletions
cmake/rpm_post_install.sh
+
1
−
1
View file @
9b079554
...
...
@@ -5,4 +5,4 @@ groupadd tarantool
useradd
-r
-g
tarantool tarantool
echo
"Performing a single instance setup"
/usr/local/bin/tarantool_
topology
.sh
-
y
1
/usr/local/bin/tarantool_
expand
.sh
-
-yes
1
This diff is collapsed.
Click to expand it.
extra/CMakeLists.txt
+
1
−
1
View file @
9b079554
...
...
@@ -15,7 +15,7 @@ if ("${CPACK_GENERATOR}" STREQUAL "RPM")
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
# chmod +x 755
install
(
FILES tarantool_
topology
.sh DESTINATION bin
install
(
FILES tarantool_
expand
.sh DESTINATION bin
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
...
...
This diff is collapsed.
Click to expand it.
extra/tarantool_expand.sh
100755 → 100644
+
71
−
40
View file @
9b079554
...
...
@@ -14,7 +14,11 @@ deploy_current=0
deploy_count
=
0
prompt_name
=
`
basename
$0
`
prompt
=
1
act_prompt
=
1
act_status
=
0
act_debug
=
0
act_dry
=
0
error
()
{
echo
"
$prompt_name
error:
$*
"
1>&2
...
...
@@ -27,8 +31,19 @@ log() {
usage
()
{
echo
"Tarantool DB expand script"
echo
"usage: tarantool_expand.sh <options> <instances>"
echo
echo
" --prefix <path> installation path (
$prefix
)"
echo
" --prefix_etc <path> installation etc path (
$prefix_etc
)"
echo
" --prefix_var <path> installation var path (
$prefix_var
)"
echo
echo
" --status display deployment status"
echo
" --dry don't create anything, show commands"
echo
echo
" --debug show commands"
echo
" --yes don't prompt"
echo
" --help display this usage"
echo
echo
"usage: tarantool_expand.sh [-y] <servers>"
exit
0
}
...
...
@@ -36,16 +51,16 @@ rollback_instance() {
id
=
$1
workdir
=
"
${
prefix_var
}
/tarantool
$id
"
config
=
"
${
prefix
}
/etc/tarantool
$id
.cfg"
rm
-rf
$workdir
rm
-f
$config
rm
-f
"
${
prefix
}
/bin/tarantool
$id
.sh"
rm
-f
"
${
prefix_etc
}
/init.d/tarantool
$id
"
rm
-f
$config
rm
-rf
$work_dir
}
rollback
()
{
log
"rollbacking changes"
for
instance
in
`
seq
$deploy_current
$deploy_count
`
;
do
log
">>>> rollbacking changes"
start
=
`
expr
$deploy_current
+ 1
`
for
instance
in
`
seq
$start
$deploy_count
`
;
do
rollback_instance
$instance
done
exit
1
...
...
@@ -53,11 +68,12 @@ rollback() {
try
()
{
cmd
=
"
$*
"
log
$cmd
eval
$cmd
if
[
$?
-gt
0
]
;
then
# log "failed: $cmd"
rollback
[
$act_debug
-gt
0
]
&&
log
$cmd
if
[
$act_dry
-eq
0
]
;
then
eval
$cmd
if
[
$?
-gt
0
]
;
then
rollback
fi
fi
}
...
...
@@ -66,21 +82,19 @@ deploy_instance() {
workdir
=
"
${
prefix_var
}
/tarantool
$id
"
config
=
"
${
prefix
}
/etc/tarantool
$id
.cfg"
log
"
--
deploying instance
$id
"
log
"
>>>>
deploying instance
$id
"
# setting up work environment
try
"mkdir -p
$workdir
/logs"
try
"chown tarantool:tarantool -R
$workdir
"
# setting up startup snapshot
try
"cp
\"
${
prefix
}
/share/tarantool/00000000000000000001.snap
\"
$workdir
"
try
"chown tarantool:tarantool -R
$workdir
"
# setting up configuration file
try
"cp
\"
${
prefix
}
/etc/tarantool.cfg
\"
$config
"
try
"echo
\"
work_dir =
\"
$workdir
\"\"
>>
$config
"
try
"echo
\"
username =
\"
tarantool
\"\"
>>
$config
"
try
"echo
\"
logger =
\"
cat -
>
> logs/tarantool.log
\"\"
>>
$config
"
try
"echo
\"
logger =
\"
cat -
\>\
>
logs/tarantool.log
\"\"
>>
$config
"
# setting up wrapper
try
"ln -s
\"
${
prefix
}
/bin/tarantool_multi.sh
\"
\"
${
prefix
}
/bin/tarantool
$id
.sh
\"
"
...
...
@@ -90,52 +104,69 @@ deploy_instance() {
}
deploy
()
{
for
instance
in
`
seq
$deploy_current
$deploy_count
`
;
do
start
=
`
expr
$deploy_current
+ 1
`
for
instance
in
`
seq
$start
$deploy_count
`
;
do
deploy_instance
$instance
done
}
update
()
{
log
"
--
updating deploy config"
try
"echo
$deploy_cu
rre
nt
>
$deploy_cfg
"
commit
()
{
log
"
>>>>
updating deploy config"
try
"echo
$deploy_c
o
unt
>
$deploy_cfg
"
}
# processing command line arguments
if
[
$#
-eq
2
]
;
then
if
[
"
$1
"
!=
"-y"
]
;
then
usage
fi
prompt
=
0
deploy_count
=
$2
else
if
[
$#
-ne
1
]
;
then
usage
fi
deploy_count
=
$1
if
[
$#
-eq
0
]
;
then
usage
fi
while
[
$#
-ge
1
]
;
do
case
$1
in
--yes
)
act_prompt
=
0
;
shift
1
;;
--prefix
)
prefix
=
$2
;
shift
2
;;
--prefix_var
)
prefix_var
=
$2
;
shift
2
;;
--prefix_etc
)
prefix_etc
=
$2
;
shift
2
;;
--dry
)
act_dry
=
1
;
act_debug
=
1
;
shift
1
;;
--debug
)
act_debug
=
1
;
shift
1
;;
--status
)
act_status
=
1
;
shift
1
;;
--help
)
usage
;
shift
1
;;
*
)
deploy_count
=
$1
;
shift
1
;
break
;;
esac
done
# validating instance number
[
$deploy_count
-eq
$deploy_count
-o
$deploy_count
-le
0
]
2>/dev/null
||
\
error
"bad instance number"
# checking deployment configuration file
if
[
-f
$deploy_cfg
]
;
then
deploy_exists
=
1
deploy_current
=
`
cat
$deploy_cfg
`
# dont' change deploy if it said so in configuration file
if
[
$deploy_current
-eq
0
]
;
then
log
"skipping deploy setup"
log
"skipping deploy setup
(cancel by config)
"
exit
0
fi
fi
# displaying status
if
[
$act_status
-ne
0
]
;
then
if
[
$deploy_exists
-eq
0
]
;
then
log
"no tarantool instances found."
else
log
"
$deploy_current
tarantool instances deployed"
fi
exit
0
fi
# validating instance number
[
$deploy_count
-eq
$deploy_count
]
2>/dev/null
&&
[
$deploy_count
-gt
0
]
||
\
error
"bad instance number"
if
[
$deploy_count
-le
$deploy_current
]
;
then
error
"expand only is supported (required instances number
$deploy_count
"
\
"is lower/equal than deployed
$deploy_current
)"
fi
# asking permission to continue
if
[
$prompt
-eq
1
]
;
then
log
"About to deploy
$deploy_current
-
$deploy_count
tarantool instances."
if
[
$act_prompt
-eq
1
]
;
then
[
$act_dry
-ne
0
]
&&
log
"(dry mode)"
log
"About to extend tarantool instances from
$deploy_current
to
$deploy_count
."
log
"Run? [n/y]"
read
answer
case
"
$answer
"
in
...
...
@@ -148,6 +179,6 @@ if [ $prompt -eq 1 ]; then
fi
deploy
update
commit
log
"done"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment