Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
d86dad76
Commit
d86dad76
authored
Mar 30, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Be more flexible about where the service binary lives for better cross platform support.
parent
9569be8b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
library/service
+7
-7
No files found.
library/service
View file @
d86dad76
...
...
@@ -33,7 +33,7 @@ args = open(argfile, 'r').read()
items
=
shlex
.
split
(
args
)
if
not
len
(
items
):
print
"failed=True msg='the module requires arguments (-a)'"
print
json
.
dumps
(
dict
(
failed
=
True
,
msg
=
'this module requires arguments (-a)'
))
sys
.
exit
(
1
)
params
=
{}
...
...
@@ -46,13 +46,13 @@ state = params.get('state','unknown')
# running and started are the same
if
state
not
in
[
'running'
,
'started'
,
'stopped'
,
'restarted'
]:
print
"failed=True msg='invalid state'"
print
json
.
dumps
(
dict
(
failed
=
True
,
msg
=
'invalid state'
))
sys
.
exit
(
1
)
# ===========================================
# get service status
status
=
os
.
popen
(
"
/sbin/
service
%
s status"
%
name
)
.
read
()
status
=
os
.
popen
(
"service
%
s status"
%
name
)
.
read
()
# ===========================================
# determine if we are going to change anything
...
...
@@ -84,12 +84,12 @@ def _run(cmd):
rc
=
0
if
changed
:
if
state
in
(
'started'
,
'running'
):
rc
=
_run
(
"
/sbin/
service
%
s start"
%
name
)
rc
=
_run
(
"service
%
s start"
%
name
)
elif
state
==
'stopped'
:
rc
=
_run
(
"
/sbin/
service
%
s stop"
%
name
)
rc
=
_run
(
"service
%
s stop"
%
name
)
elif
state
==
'restarted'
:
rc1
=
_run
(
"
/sbin/
service
%
s stop"
%
name
)
rc2
=
_run
(
"
/sbin/
service
%
s start"
%
name
)
rc1
=
_run
(
"service
%
s stop"
%
name
)
rc2
=
_run
(
"service
%
s start"
%
name
)
rc
=
rc1
and
rc2
if
rc
!=
0
:
...
...
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