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
d86d725a
Commit
d86d725a
authored
10 years ago
by
Konstantin Osipov
Browse files
Options
Downloads
Patches
Plain Diff
tarantoolctl: support user level configuration file
~/.config/tarantool superseeds /etc/default, not augments it
parent
8852434e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
extra/dist/tarantoolctl
+49
-35
49 additions, 35 deletions
extra/dist/tarantoolctl
with
49 additions
and
35 deletions
extra/dist/tarantoolctl
+
49
−
35
View file @
d86d725a
...
@@ -106,25 +106,22 @@ local fiber = require 'fiber'
...
@@ -106,25 +106,22 @@ local fiber = require 'fiber'
ffi
.
cdef
[[ int kill(int pid, int sig); ]]
ffi
.
cdef
[[ int kill(int pid, int sig); ]]
configs
=
{
local
config_file
=
os.getenv
(
'HOME'
)
..
'/.config/tarantool/tarantool'
system
=
nil
,
local
usermode
=
true
user
=
os.getenv
(
'HOME'
)
..
'/.config/tarantool/tarantool'
,
}
if
not
fio
.
stat
(
config_file
)
then
usermode
=
false
if
not
fio
.
stat
(
configs
.
user
)
then
local
config_list
=
{
configs
.
user
=
nil
'/etc/sysconfig/tarantool'
,
end
'/etc/default/tarantool'
,
'/usr/local/etc/tarantool/tarantool'
,
config_list
=
{
}
'/etc/sysconfig/tarantool'
,
'/etc/default/tarantool'
,
'/usr/local/etc/tarantool/tarantool'
,
}
for
_
,
c
in
pairs
(
config_list
)
do
for
_
,
c
in
pairs
(
config_list
)
do
if
fio
.
stat
(
c
)
then
if
fio
.
stat
(
c
)
then
configs
.
system
=
c
config_file
=
c
break
break
end
end
end
end
end
...
@@ -134,15 +131,14 @@ local available_commands = {
...
@@ -134,15 +131,14 @@ local available_commands = {
'logrotate'
,
'logrotate'
,
'status'
,
'status'
,
'enter'
,
'enter'
,
'restart'
'restart'
,
'reload'
}
}
local
function
usage
()
local
function
usage
()
log
.
error
(
"Usage: %s {%s} instance_name"
,
log
.
error
(
"Usage: %s {%s} instance_name"
,
arg
[
0
],
table.concat
(
available_commands
,
'|'
))
arg
[
0
],
table.concat
(
available_commands
,
'|'
))
for
c
,
f
in
pairs
(
configs
)
do
log
.
error
(
"Config file: %s"
,
config_file
)
log
.
error
(
"Config [%6s]: %s"
,
c
,
f
)
end
os.exit
(
1
)
os.exit
(
1
)
end
end
...
@@ -190,18 +186,16 @@ shift_argv(arg, 0, 2)
...
@@ -190,18 +186,16 @@ shift_argv(arg, 0, 2)
local
instance_lua
=
nil
local
instance_lua
=
nil
for
_
,
c
in
pairs
({
'user'
,
'system'
})
do
dofile
(
configs
[
c
])
dofile
(
config_file
)
if
instance_dir
then
if
instance_dir
then
instance_lua
=
fio
.
pathjoin
(
instance_dir
,
instance
..
'.lua'
)
instance_lua
=
fio
.
pathjoin
(
instance_dir
,
instance
..
'.lua'
)
if
fio
.
stat
(
instance_lua
)
then
if
fio
.
stat
(
instance_lua
)
then
log
.
info
(
'Found %s.lua in %s'
,
instance
,
instance_dir
)
log
.
info
(
'Found %s.lua in %s'
,
instance
,
instance_dir
)
break
end
end
end
instance_dir
=
nil
instance_lua
=
nil
end
end
instance_dir
=
nil
instance_lua
=
nil
if
default_cfg
==
nil
then
if
default_cfg
==
nil
then
default_cfg
=
{}
default_cfg
=
{}
...
@@ -217,7 +211,10 @@ default_cfg.wal_dir = default_cfg.wal_dir and default_cfg.wal_dir or "/var/li
...
@@ -217,7 +211,10 @@ default_cfg.wal_dir = default_cfg.wal_dir and default_cfg.wal_dir or "/var/li
default_cfg
.
snap_dir
=
default_cfg
.
snap_dir
and
default_cfg
.
snap_dir
or
"/var/lib/tarantool"
default_cfg
.
snap_dir
=
default_cfg
.
snap_dir
and
default_cfg
.
snap_dir
or
"/var/lib/tarantool"
default_cfg
.
sophia_dir
=
default_cfg
.
sophia_dir
and
default_cfg
.
sophia_dir
or
"/var/lib/tarantool"
default_cfg
.
sophia_dir
=
default_cfg
.
sophia_dir
and
default_cfg
.
sophia_dir
or
"/var/lib/tarantool"
default_cfg
.
logger
=
default_cfg
.
logger
and
default_cfg
.
logger
or
"/var/log/tarantool"
default_cfg
.
logger
=
default_cfg
.
logger
and
default_cfg
.
logger
or
"/var/log/tarantool"
default_cfg
.
username
=
default_cfg
.
username
and
default_cfg
.
username
or
"tarantool"
-- change user name only if not running locally
if
not
usermode
then
default_cfg
.
username
=
default_cfg
.
username
and
default_cfg
.
username
or
"tarantool"
end
-- create a path to the control socket (admin console)
-- create a path to the control socket (admin console)
local
console_sock
=
fio
.
pathjoin
(
default_cfg
.
pid_file
,
instance
..
'.control'
)
local
console_sock
=
fio
.
pathjoin
(
default_cfg
.
pid_file
,
instance
..
'.control'
)
...
@@ -237,7 +234,7 @@ local function mkdir(dirname)
...
@@ -237,7 +234,7 @@ local function mkdir(dirname)
os.exit
(
-
1
)
os.exit
(
-
1
)
end
end
if
not
fio
.
chown
(
dirname
,
default_cfg
.
username
,
default_cfg
.
username
)
then
if
not
usermode
and
not
fio
.
chown
(
dirname
,
default_cfg
.
username
,
default_cfg
.
username
)
then
log
.
error
(
"Can't chown(%s, %s, %s): %s"
,
log
.
error
(
"Can't chown(%s, %s, %s): %s"
,
default_cfg
.
username
,
default_cfg
.
username
,
dirname
,
errno
.
strerror
())
default_cfg
.
username
,
default_cfg
.
username
,
dirname
,
errno
.
strerror
())
end
end
...
@@ -334,7 +331,14 @@ end
...
@@ -334,7 +331,14 @@ end
function
start
()
function
start
()
log
.
info
(
"Starting instance..."
)
log
.
info
(
"Starting instance..."
)
box
.
cfg
=
wrapper_cfg
box
.
cfg
=
wrapper_cfg
dofile
(
instance_lua
)
local
success
,
data
=
pcall
(
dofile
,
instance_lua
)
-- if load fails - show last 10 lines of the log file
if
not
success
then
print
(
'Start failed: '
..
data
)
if
fio
.
stat
(
default_cfg
.
logger
)
then
os.execute
(
'tail -n 10 '
..
default_cfg
.
logger
)
end
end
end
end
...
@@ -388,6 +392,7 @@ elseif cmd == 'enter' then
...
@@ -388,6 +392,7 @@ elseif cmd == 'enter' then
elseif
cmd
==
'status'
then
elseif
cmd
==
'status'
then
if
fio
.
stat
(
force_cfg
.
pid_file
)
==
nil
then
if
fio
.
stat
(
force_cfg
.
pid_file
)
==
nil
then
if
errno
()
==
errno
.
ENOENT
then
if
errno
()
==
errno
.
ENOENT
then
print
(
instance
..
' is stopped (pid file does not exist)'
)
os.exit
(
1
)
os.exit
(
1
)
end
end
log
.
error
(
"Cant access pidfile %s: %s"
,
log
.
error
(
"Cant access pidfile %s: %s"
,
...
@@ -414,7 +419,16 @@ elseif cmd == 'status' then
...
@@ -414,7 +419,16 @@ elseif cmd == 'status' then
end
end
s
:
close
()
s
:
close
()
print
(
instance
..
' is running (pid:'
..
force_cfg
.
pid_file
..
')'
)
os.exit
(
0
)
os.exit
(
0
)
elseif
cmd
==
'reload'
then
if
fio
.
stat
(
arg
[
2
])
==
nil
then
if
errno
()
==
errno
.
ENOENT
then
print
(
arg
[
2
]
..
': file not found'
)
os.exit
(
1
)
end
end
dofile
(
arg
[
2
])
else
else
log
.
error
(
"Unknown command '%s'"
,
cmd
)
log
.
error
(
"Unknown command '%s'"
,
cmd
)
os.exit
(
-
1
)
os.exit
(
-
1
)
...
...
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