Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve pserve deprecation messages #2120

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,18 @@ Bug Fixes
Deprecations
------------

- The ``pserve`` command's daemonization features have been deprecated. This
includes the ``[start,stop,restart,status]`` subcommands as well as the
``--daemon``, ``--stop-server``, ``--pid-file``, and ``--status`` flags.
- The ``pserve`` command's daemonization features have been deprecated as well
as ``--monitor-restart``. This includes the ``[start,stop,restart,status]``
subcommands as well as the ``--daemon``, ``--stop-daemon``, ``--pid-file``,
and ``--status`` flags.

Please use a real process manager in the future instead of relying on the
``pserve`` to daemonize itself. Many options exist including your Operating
System's services such as Systemd or Upstart, as well as Python-based
solutions like Circus and Supervisor.

See https://github.com/Pylons/pyramid/pull/1641
and https://github.com/Pylons/pyramid/pull/2120

- Renamed the ``principal`` argument to ``pyramid.security.remember()`` to
``userid`` in order to clarify its intended purpose.
Expand Down
23 changes: 18 additions & 5 deletions pyramid/scripts/pserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class PServeCommand(object):

If start/stop/restart is given, then --daemon is implied, and it will
start (normal operation), stop (--stop-daemon), or do both.
Note: Daemonization features are deprecated.

You can also include variable assignments like 'http_port=8080'
and then use %(http_port)s in your config files.
Expand Down Expand Up @@ -100,13 +101,13 @@ class PServeCommand(object):
'--daemon',
dest="daemon",
action="store_true",
help="Run in daemon (background) mode")
help="Run in daemon (background) mode [DEPRECATED]")
parser.add_option(
'--pid-file',
dest='pid_file',
metavar='FILENAME',
help=("Save PID to file (default to pyramid.pid if running in "
"daemon mode)"))
"daemon mode) [DEPRECATED]"))
parser.add_option(
'--log-file',
dest='log_file',
Expand All @@ -127,7 +128,7 @@ class PServeCommand(object):
'--monitor-restart',
dest='monitor_restart',
action='store_true',
help="Auto-restart server if it dies")
help="Auto-restart server if it dies [DEPRECATED]")
parser.add_option(
'-b', '--browser',
dest='browser',
Expand All @@ -137,7 +138,8 @@ class PServeCommand(object):
'--status',
action='store_true',
dest='show_status',
help="Show the status of the (presumably daemonized) server")
help=("Show the status of the (presumably daemonized) server "
"[DEPRECATED]"))
parser.add_option(
'-v', '--verbose',
default=default_verbosity,
Expand Down Expand Up @@ -169,7 +171,7 @@ class PServeCommand(object):
dest='stop_daemon',
action='store_true',
help=('Stop a daemonized server (given a PID file, or default '
'pyramid.pid file)'))
'pyramid.pid file) [DEPRECATED]'))

_scheme_re = re.compile(r'^[a-z][a-z]+:', re.I)

Expand Down Expand Up @@ -302,6 +304,17 @@ def run(self): # pragma: no cover
raise ValueError(msg)
writeable_pid_file.close()

# warn before forking
if (
self.options.monitor_restart and
not os.environ.get(self._monitor_environ_key)
):
self.out('''\
--monitor-restart has been deprecated in Pyramid 1.6. It will be removed
in a future release per Pyramid's deprecation policy. Please consider using
a real process manager for your processes like Systemd, Circus, or Supervisor.
''')

if (
getattr(self.options, 'daemon', False) and
not os.environ.get(self._monitor_environ_key)
Expand Down