| 1 | # GNU MediaGoblin -- federated, autonomous media hosting |
| 2 | # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. |
| 3 | # |
| 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. |
| 8 | # |
| 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. |
| 13 | # |
| 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/>. |
| 16 | |
| 17 | from __future__ import print_function |
| 18 | |
| 19 | from paste.deploy import loadapp, loadserver |
| 20 | |
| 21 | |
| 22 | class ServeCommand(object): |
| 23 | |
| 24 | def loadserver(self, server_spec, name, relative_to, **kwargs): |
| 25 | return loadserver(server_spec, name=name, relative_to=relative_to, |
| 26 | **kwargs) |
| 27 | |
| 28 | def loadapp(self, app_spec, name, relative_to, **kwargs): |
| 29 | return loadapp(app_spec, name=name, relative_to=relative_to, **kwargs) |
| 30 | |
| 31 | def daemonize(self): |
| 32 | pass |
| 33 | |
| 34 | def restart_with_reloader(self): |
| 35 | pass |
| 36 | |
| 37 | def restart_with_monitor(self, reloader=False): |
| 38 | pass |
| 39 | |
| 40 | def run(self): |
| 41 | print('Running...') |
| 42 | |
| 43 | |
| 44 | def parser_setup(subparser): |
| 45 | subparser.add_argument('config', metavar='CONFIG_FILE') |
| 46 | subparser.add_argument('command', |
| 47 | choices=['start', 'stop', 'restart', 'status'], |
| 48 | nargs='?', default='start') |
| 49 | subparser.add_argument('-n', '--app-name', |
| 50 | dest='app_name', |
| 51 | metavar='NAME', |
| 52 | help="Load the named application (default main)") |
| 53 | subparser.add_argument('-s', '--server', |
| 54 | dest='server', |
| 55 | metavar='SERVER_TYPE', |
| 56 | help="Use the named server.") |
| 57 | subparser.add_argument('--reload', |
| 58 | dest='reload', |
| 59 | action='store_true', |
| 60 | help="Use auto-restart file monitor") |
| 61 | |
| 62 | |
| 63 | def serve(args): |
| 64 | serve_cmd = ServeCommand() # TODO: pass args to it |
| 65 | serve_cmd.run() |