1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 from __future__
import print_function
19 from paste
.deploy
import loadapp
, loadserver
22 class ServeCommand(object):
24 def loadserver(self
, server_spec
, name
, relative_to
, **kwargs
):
25 return loadserver(server_spec
, name
=name
, relative_to
=relative_to
,
28 def loadapp(self
, app_spec
, name
, relative_to
, **kwargs
):
29 return loadapp(app_spec
, name
=name
, relative_to
=relative_to
, **kwargs
)
32 # TODO: pass to gunicorn if available
35 def restart_with_reloader(self
):
38 def restart_with_monitor(self
, reloader
=False):
45 def parser_setup(subparser
):
46 subparser
.add_argument('config', metavar
='CONFIG_FILE')
47 subparser
.add_argument('command',
48 choices
=['start', 'stop', 'restart', 'status'],
49 nargs
='?', default
='start')
50 subparser
.add_argument('-n', '--app-name',
53 help="Load the named application (default main)")
54 subparser
.add_argument('-s', '--server',
56 metavar
='SERVER_TYPE',
57 help="Use the named server.")
58 subparser
.add_argument('--reload',
61 help="Use auto-restart file monitor")
65 serve_cmd
= ServeCommand() # TODO: pass args to it