Don't chdir when running as a daemon #1547

Merged
merged 3 commits into from Jan 11, 2017

Projects

Done in Features

3 participants

@webknjaz
Collaborator
webknjaz commented Jan 9, 2017

Fixes #1546

@jaraco do you know the purpose of that os.chdir('/')?

@webknjaz
Collaborator

@jaraco Do you agree with removing chdir (7d54519)? This is the only question stopping me from merging this PR.

@webknjaz
Collaborator

there's also an option to chdir to _module__file__base instead.

webknjaz added some commits Jan 7, 2017
@webknjaz webknjaz Convert cherryd script into console_script
Also:
* remove ``cherrypy/cherryd``
* run cherryd as cherrypy.__main__ module to support Python 2.6
116dc27
@webknjaz webknjaz Fix autoreload for cherryd loaded as a module
Also:
* raise RuntimeError when trying to reconstruct `-c`
* run cherryd as cherrypy.__main__ module to support Python 2.6

Ref: #1545
Ref: python/cpython@418baf9
762c98a
@webknjaz webknjaz Don't chdir when running as a daemon
Fixes #1546
9bcf3fb
@webknjaz webknjaz requested a review from jaraco Jan 11, 2017
+ if is_module:
+ """It's containing `-m -m` sequence of arguments"""
+ if is_command and c_ind < m_ind:
+ """There's `-c -c` before `-m`"""
+ # ... and substitute it with the original module path:
+ _argv.insert(m_ind, original_module)
+ elif is_command:
+ """It's containing just `-c -c` sequence of arguments"""
+ # Survive module argument here
+ original_module = sys.argv[0]
+ if not os.access(original_module, os.R_OK):
+ """There's no such module exist"""
+ c_ind = None
+
+ if is_module:
+ """It's containing `-m -m` sequence of arguments"""
@codacy-bot

Codacy Here is an overview of what got changed by this pull request:

Issues
======
- Added 5
           

Complexity increasing per file
==============================
- cherrypy/process/wspbus.py  4
         

See the complete overview on Codacy

+
+ doesn't work as it's impossible to reconstruct the `-c`'s contents.
+ Ref: https://github.com/cherrypy/cherrypy/issues/1545
+ """
@jaraco jaraco merged commit 2ce092b into master Jan 11, 2017

4 of 5 checks passed

codacy/pr Not so good... This pull request quality could be better.
Details
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@jaraco jaraco added a commit that referenced this pull request Jan 13, 2017
@jaraco jaraco Update changelog. Ref #1547. deebb8f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment