forked from celery/celery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crossplatform log and pid files in multi mode
it relates to celery#6017
- Loading branch information
1 parent
736e93d
commit a6171e6
Showing
2 changed files
with
14 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import errno | ||
import signal | ||
import sys | ||
import os | ||
|
||
import pytest | ||
from case import Mock, call, patch, skip | ||
|
@@ -113,8 +114,8 @@ def assert_line_in(name, args): | |
|
||
def _args(name, *args): | ||
return args + ( | ||
'--pidfile=/var/run/celery/{}.pid'.format(name), | ||
'--logfile=/var/log/celery/{}%I.log'.format(name), | ||
'--pidfile={}.pid'.format(os.path.join(os.path.normpath('/var/run/celery/'), name)), | ||
'--logfile={}%I.log'.format(os.path.join(os.path.normpath('/var/log/celery/'), name)), | ||
'--executable={0}'.format(sys.executable), | ||
'', | ||
) | ||
|
@@ -194,10 +195,10 @@ def test_from_kwargs(self): | |
'--executable={0}'.format(n.executable), | ||
'-O fair', | ||
'-n [email protected]', | ||
'--logfile=/var/log/celery/foo%I.log', | ||
'--logfile={}'.format(os.path.normpath('/var/log/celery/foo%I.log')), | ||
'-Q q1,q2', | ||
'--max-tasks-per-child=30', | ||
'--pidfile=/var/run/celery/foo.pid', | ||
'--pidfile={}'.format(os.path.normpath('/var/run/celery/foo.pid')), | ||
'', | ||
]) | ||
|
||
|
@@ -275,7 +276,7 @@ def test_handle_process_exit__signalled(self): | |
|
||
def test_logfile(self): | ||
assert self.node.logfile == self.expander.return_value | ||
self.expander.assert_called_with('/var/log/celery/%n%I.log') | ||
self.expander.assert_called_with(os.path.normpath('/var/log/celery/%n%I.log')) | ||
|
||
|
||
class test_Cluster: | ||
|
@@ -375,8 +376,8 @@ def test_getpids(self): | |
assert sorted(node_0.argv) == sorted([ | ||
'', | ||
'--executable={0}'.format(node_0.executable), | ||
'--logfile=/var/log/celery/foo%I.log', | ||
'--pidfile=/var/run/celery/foo.pid', | ||
'--logfile={}'.format(os.path.normpath('/var/log/celery/foo%I.log')), | ||
'--pidfile={}'.format(os.path.normpath('/var/run/celery/foo.pid')), | ||
'-m celery worker --detach', | ||
'-n [email protected]', | ||
]) | ||
|
@@ -386,8 +387,8 @@ def test_getpids(self): | |
assert sorted(node_1.argv) == sorted([ | ||
'', | ||
'--executable={0}'.format(node_1.executable), | ||
'--logfile=/var/log/celery/bar%I.log', | ||
'--pidfile=/var/run/celery/bar.pid', | ||
'--logfile={}'.format(os.path.normpath('/var/log/celery/bar%I.log')), | ||
'--pidfile={}'.format(os.path.normpath('/var/run/celery/bar.pid')), | ||
'-m celery worker --detach', | ||
'-n [email protected]', | ||
]) | ||
|
@@ -404,8 +405,8 @@ def __init__(self, path): | |
|
||
def read_pid(self): | ||
try: | ||
return {'/var/run/celery/foo.pid': 10, | ||
'/var/run/celery/bar.pid': 11}[self.path] | ||
return {os.path.normpath('/var/run/celery/foo.pid'): 10, | ||
os.path.normpath('/var/run/celery/bar.pid'): 11}[self.path] | ||
except KeyError: | ||
raise ValueError() | ||
self.Pidfile.side_effect = pids |