Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
prunner
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Konstantin Artyushkin
prunner
Commits
cf2a5c34
Commit
cf2a5c34
authored
Mar 08, 2018
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for parameter '-r','--run'
parent
bf981df4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
32 deletions
+69
-32
README.md
README.md
+21
-15
prunner
prunner
+48
-17
No files found.
README.md
View file @
cf2a5c34
...
@@ -11,17 +11,18 @@ Depends
...
@@ -11,17 +11,18 @@ Depends
Usage
Usage
-----
-----
prunner -p pid
[
-d dir | -f file
]
prunner -p pid
[
-d dir | -f file
| -r '[params
]
prog args..'
]
Help
Help
----
----
-d | --run-from-dir dir - run programm from directory
-d | --run-from-dir dir - run programm from directory
-f | --run-from-file file - run programm from file
-f | --run-from-file file - run programm from file
-p | --monitor-pid pid - pid of main process (for monitoring)
-r | --run '
[
params
]
prog args..' - run programm from command line"
-v | --verbose - Print info messages
-p | --monitor-pid pid - pid of main process (for monitoring)
--disable-monitor - only run process
-v | --verbose - Print info messages
-c | --check-period sec - period for check processes. Default: 5 sec
--disable-monitor - only run process
-t | --terminate-timeout sec - timeout for teminate processes (then the processes will be killed). Default: 5 sec
-c | --check-period sec - period for check processes. Default: 5 sec
-t | --terminate-timeout sec - timeout for teminate processes (then the processes will be killed). Default: 5 sec
Example 1 (run from directory)
Example 1 (run from directory)
------------------------------
------------------------------
...
@@ -40,13 +41,13 @@ Example 2 (run from file)
...
@@ -40,13 +41,13 @@ Example 2 (run from file)
-------------------------
-------------------------
cat runlist.txt
cat runlist.txt
[
restart
]
prog1
[
restart
]
prog1
arg1 arg2
# comment 1
# comment 1
[
ignore_fail,restart
]
prog2
[
ignore_fail,restart
]
prog2
arg1 arg2
# comment 2
# comment 2
[
verbose,shell=False
]
prog3
[
verbose,shell=False
]
prog3
prog4
prog4
arg1 arg2
prog5
prog5
arg1
prunner -p PID -f ./runlist.txt
prunner -p PID -f ./runlist.txt
...
@@ -76,7 +77,12 @@ Example 2 (run from file)
...
@@ -76,7 +77,12 @@ Example 2 (run from file)
"restart=1,ignore_fail=1" - игнорировать неудачные запуски, но пытаться снова перезапускать
"restart=1,ignore_fail=1" - игнорировать неудачные запуски, но пытаться снова перезапускать
</code>
</code>
Example 3
Example 3 (run from command line)
---------------------------------
prunner -p PID -r '
[
restart
]
prog1 arg1 arg2' -r '
[
restart=0,verbose
]
prog2 arg1 arg2' --run '
[
shell=0,ignore_fail=0
]
prog3 arg1 arg2'
Example 4
---------
---------
prunner -p PID -d ./child.d -f runlist.txt
prunner -p PID -d ./child.d -f runlist.txt
-r '
[
restart
]
prog1 arg1 arg2'
Т.е. можно указывать и каталог и файл одновременно
Т.е. можно указывать и каталог и файл
и -r
одновременно
prunner
View file @
cf2a5c34
...
@@ -262,15 +262,11 @@ def read_from_file(fname):
...
@@ -262,15 +262,11 @@ def read_from_file(fname):
if
len
(
line
)
==
0
or
line
.
startswith
(
"#"
):
if
len
(
line
)
==
0
or
line
.
startswith
(
"#"
):
continue
continue
p
=
None
if
line
.
startswith
(
"["
):
if
line
.
startswith
(
"["
):
cmd
,
params
=
parse_run_parameters
(
line
)
cmd
,
params
=
parse_run_parameters
(
line
)
p
=
ChildProc
(
cmd
=
cmd
,
params
=
params
)
run_list
.
append
(
ChildProc
(
cmd
=
cmd
,
params
=
params
))
else
:
if
not
p
:
run_list
.
append
(
ChildProc
(
cmd
=
line
))
p
=
ChildProc
(
cmd
=
line
)
run_list
.
append
(
p
)
return
run_list
return
run_list
...
@@ -281,10 +277,8 @@ def read_from_dir(dname):
...
@@ -281,10 +277,8 @@ def read_from_dir(dname):
:param dname: directory name (path)
:param dname: directory name (path)
:return: list of 'ChildProc' objects
:return: list of 'ChildProc' objects
"""
"""
ret
=
list
()
if
not
os
.
path
.
exists
(
dname
):
if
not
os
.
path
.
exists
(
dname
):
return
ret
return
list
()
plist
=
list
()
plist
=
list
()
for
f
in
os
.
listdir
(
dname
):
for
f
in
os
.
listdir
(
dname
):
...
@@ -294,14 +288,49 @@ def read_from_dir(dname):
...
@@ -294,14 +288,49 @@ def read_from_dir(dname):
return
plist
return
plist
def
read_from_commandline
(
param
):
params
=
list
()
if
isinstance
(
param
,
list
):
params
=
param
else
:
params
.
append
(
param
)
plist
=
list
()
skip
=
False
for
i
in
range
(
0
,
len
(
sys
.
argv
)):
if
skip
:
skip
=
False
continue
if
sys
.
argv
[
i
]
in
params
:
if
i
+
1
>=
len
(
sys
.
argv
):
break
arg
=
sys
.
argv
[
i
+
1
]
if
arg
.
startswith
(
'-'
)
or
arg
.
startswith
(
'--'
):
log_info
(
"(read_from_commandline): ignore '
%
s' because an argument is required..."
%
sys
.
argv
[
i
])
continue
skip
=
True
if
arg
.
startswith
(
"["
):
cmd
,
params
=
parse_run_parameters
(
arg
)
plist
.
append
(
ChildProc
(
cmd
=
cmd
,
params
=
params
))
else
:
plist
.
append
(
ChildProc
(
cmd
=
arg
))
return
plist
def
usage
():
def
usage
():
print
"-d|--run-from-dir dir - run programm from directory"
print
"[-d|--run-from-dir] dir - run programm from directory"
print
"-f|--run-from-file file - run programm from file"
print
"[-f|--run-from-file] file - run programm from file"
print
"-p|--monitor-pid pid - pid of main process (for monitoring)"
print
"[-r|--run] '[params]prog' - run programm from command line"
print
"-v|--verbose - Print info messages"
print
"[-p|--monitor-pid] pid - pid of main process (for monitoring)"
print
"--disable-monitor - only run process"
print
"[-v|--verbose] - Print info messages"
print
"-c|--check-period sec - period for check processes. Default:
%
s"
%
check_alive_period
print
"--disable-monitor - only run process"
print
"-t|--terminate-timeout sec - timeout for teminate processes (then the processes will be killed). Default:
%
s"
%
timeout_for_terminate
print
"[-c|--check-period] sec - period for check processes. Default:
%
s"
%
check_alive_period
print
"[-t|--terminate-timeout] sec - timeout for teminate processes (then the processes will be killed). Default:
%
s"
%
timeout_for_terminate
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
@@ -335,6 +364,8 @@ if __name__ == "__main__":
...
@@ -335,6 +364,8 @@ if __name__ == "__main__":
if
len
(
from_dir
):
if
len
(
from_dir
):
run_list
=
run_list
+
read_from_dir
(
from_dir
)
run_list
=
run_list
+
read_from_dir
(
from_dir
)
run_list
=
run_list
+
read_from_commandline
([
'-r'
,
'--run'
])
if
len
(
run_list
)
==
0
:
if
len
(
run_list
)
==
0
:
log_error
(
"not found run list. Use -h for help"
)
log_error
(
"not found run list. Use -h for help"
)
exit
(
1
)
exit
(
1
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment