Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#9167 closed (wontfix)

shutdown_message option missing in runserver.py

Reported by: jjackson Owned by: nobody
Component: django-admin.py runserver Version: 1.0
Severity: Keywords:
Cc: jjackson@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

Description

Changeset 5911 added a shutdown_message option in runserver.py, but it was never fully implemented. In Ticket #8085, you can see it being used, but it doesn't work because the option isn't included using 'make_option'. Running in 1.0:

LosOlivos: $ python -u mysite/manage.py runserver --noreload --shutdown_message 'Shutdown message for server.' 
Usage: mysite/manage.py runserver [options] [optional port number, or ipaddr:port]

Starts a lightweight Web server for development.

mysite/manage.py: error: no such option: --shutdown_message
Exception: <type 'exceptions.SystemExit'>

What's missing is the last make_option shown in this code:

class Command(BaseCommand):
    option_list = BaseCommand.option_list + (
        make_option('--noreload', action='store_false', dest='use_reloader', default=True,
            help='Tells Django to NOT use the auto-reloader.'),
        make_option('--adminmedia', dest='admin_media_path', default='',
            help='Specifies the directory from which to serve admin media.'),
        make_option('--shutdown_message', dest='shutdown_message', default='',
            help='Specifies a message displayed when shutting down the server.'),
    )

One thing I'm not sure about is what to do when the message is printed, as the message may need a '\n' before it. What I got was this, with the Control-C and the message run together:

LosOlivos: $ python -u mysite/manage.py runserver --noreload --shutdown_message 'Shutdown message for server.' 
Validating models...
0 errors found

Django version 1.0-final-SVN-unknown, using settings 'mysite.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
^CShutdown message for server.
Exception: <type 'exceptions.SystemExit'>

Change History (7)

comment:1 Changed 6 years ago by jjackson

  • Has patch set
  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset

To fix the problem of the Control-C, change the inner_run method:

            except KeyboardInterrupt:
                if shutdown_message:
                    print '\n'+shutdown_message
                sys.exit(0)

comment:2 Changed 6 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:3 Changed 6 years ago by jacob

  • milestone set to 1.1
  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 6 years ago by russellm

  • Component changed from Uncategorized to django-admin.py runserver

comment:5 Changed 6 years ago by jacob

  • Resolution set to wontfix
  • Status changed from new to closed

Looking back at [5911], it's obvious from the next commit ([5912]) that this bit was intended for internal use -- it's used by the testserver command. I don't see the point on making this a public API.

comment:6 Changed 6 years ago by jjackson

I don't see that this is "obvious from the next commit ([5912]) that this bit was intended for internal use". I use this in an application I wrote for a demo Django Server to send to prospective clients, and it allows me to provide feedback that the server is shutting down. It's being used as shown in Ticket #8085, but it doesn't work the way it's currently configured. It's not as if omitting this is going to keep this hidden.

And, it's not as if the testserver can use the 'shutdown message" option either: the way it is, it's just broken. If you don't want it exposed, you should instead remove it all, as the code doesn't even work as an "internal use" only, whatever that means.

Since I use it personally, I'll just keep adding it back into my projects....

comment:7 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top