Merge "Use entry_points for server executables"

This commit is contained in:
Zuul 2024-07-10 02:35:47 +00:00 committed by Gerrit Code Review
commit 9c38d756e0
9 changed files with 62 additions and 31 deletions

View File

@ -14,10 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import sys from swift.account import server
from swift.common.utils import parse_options
from swift.common.wsgi import run_wsgi
if __name__ == '__main__': if __name__ == '__main__':
conf_file, options = parse_options(test_config=True) server.main()
sys.exit(run_wsgi(conf_file, 'account-server', **options))

View File

@ -14,10 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import sys from swift.container import server
from swift.common.utils import parse_options
from swift.common.wsgi import run_wsgi
if __name__ == '__main__': if __name__ == '__main__':
conf_file, options = parse_options(test_config=True) server.main()
sys.exit(run_wsgi(conf_file, 'container-server', **options))

View File

@ -14,14 +14,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import sys
from swift.common.utils import parse_options
from swift.common.wsgi import run_wsgi
from swift.obj import server from swift.obj import server
if __name__ == '__main__': if __name__ == '__main__':
conf_file, options = parse_options(test_config=True) server.main()
sys.exit(run_wsgi(conf_file, 'object-server',
global_conf_callback=server.global_conf_callback,
**options))

View File

@ -14,10 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import sys from swift.proxy import server
from swift.common.utils import parse_options
from swift.common.wsgi import run_wsgi
if __name__ == '__main__': if __name__ == '__main__':
conf_file, options = parse_options(test_config=True) server.main()
sys.exit(run_wsgi(conf_file, 'proxy-server', **options))

View File

@ -47,12 +47,10 @@ scripts =
bin/swift-account-info bin/swift-account-info
bin/swift-account-reaper bin/swift-account-reaper
bin/swift-account-replicator bin/swift-account-replicator
bin/swift-account-server
bin/swift-config bin/swift-config
bin/swift-container-auditor bin/swift-container-auditor
bin/swift-container-info bin/swift-container-info
bin/swift-container-replicator bin/swift-container-replicator
bin/swift-container-server
bin/swift-container-sharder bin/swift-container-sharder
bin/swift-container-sync bin/swift-container-sync
bin/swift-container-updater bin/swift-container-updater
@ -70,11 +68,9 @@ scripts =
bin/swift-object-replicator bin/swift-object-replicator
bin/swift-object-reconstructor bin/swift-object-reconstructor
bin/swift-object-relinker bin/swift-object-relinker
bin/swift-object-server
bin/swift-object-updater bin/swift-object-updater
bin/swift-oldies bin/swift-oldies
bin/swift-orphans bin/swift-orphans
bin/swift-proxy-server
bin/swift-recon bin/swift-recon
bin/swift-recon-cron bin/swift-recon-cron
bin/swift-ring-builder bin/swift-ring-builder
@ -94,8 +90,12 @@ keystone =
[entry_points] [entry_points]
console_scripts = console_scripts =
swift-manage-shard-ranges = swift.cli.manage_shard_ranges:main swift-account-server = swift.account.server:main
swift-container-deleter = swift.cli.container_deleter:main swift-container-deleter = swift.cli.container_deleter:main
swift-container-server = swift.container.server:main
swift-manage-shard-ranges = swift.cli.manage_shard_ranges:main
swift-object-server = swift.obj.server:main
swift-proxy-server = swift.proxy.server:main
swift-reload = swift.cli.reload:main swift-reload = swift.cli.reload:main
paste.app_factory = paste.app_factory =

View File

@ -15,6 +15,7 @@
import json import json
import os import os
import sys
import time import time
import traceback import traceback
@ -30,7 +31,7 @@ from swift.common.request_helpers import get_param, \
from swift.common.utils import get_logger, hash_path, public, \ from swift.common.utils import get_logger, hash_path, public, \
Timestamp, storage_directory, config_true_value, \ Timestamp, storage_directory, config_true_value, \
timing_stats, replication, get_log_line, \ timing_stats, replication, get_log_line, \
config_fallocate_value, fs_has_free_space config_fallocate_value, fs_has_free_space, parse_options
from swift.common.constraints import valid_timestamp, check_utf8, \ from swift.common.constraints import valid_timestamp, check_utf8, \
check_drive, AUTO_CREATE_ACCOUNT_PREFIX check_drive, AUTO_CREATE_ACCOUNT_PREFIX
from swift.common import constraints from swift.common import constraints
@ -43,6 +44,7 @@ from swift.common.swob import HTTPAccepted, HTTPBadRequest, \
HTTPPreconditionFailed, HTTPConflict, Request, \ HTTPPreconditionFailed, HTTPConflict, Request, \
HTTPInsufficientStorage, HTTPException, wsgi_to_str HTTPInsufficientStorage, HTTPException, wsgi_to_str
from swift.common.request_helpers import is_sys_or_user_meta from swift.common.request_helpers import is_sys_or_user_meta
from swift.common.wsgi import run_wsgi
def get_account_name_and_placement(req): def get_account_name_and_placement(req):
@ -339,3 +341,12 @@ def app_factory(global_conf, **local_conf):
conf = global_conf.copy() conf = global_conf.copy()
conf.update(local_conf) conf.update(local_conf)
return AccountController(conf) return AccountController(conf)
def main():
conf_file, options = parse_options(test_config=True)
sys.exit(run_wsgi(conf_file, 'account-server', **options))
if __name__ == '__main__':
main()

View File

@ -15,6 +15,7 @@
import json import json
import os import os
import sys
import time import time
import traceback import traceback
@ -38,7 +39,7 @@ from swift.common.utils import get_logger, hash_path, public, \
config_true_value, timing_stats, replication, \ config_true_value, timing_stats, replication, \
override_bytes_from_content_type, get_log_line, \ override_bytes_from_content_type, get_log_line, \
config_fallocate_value, fs_has_free_space, list_from_csv, \ config_fallocate_value, fs_has_free_space, list_from_csv, \
ShardRange ShardRange, parse_options
from swift.common.constraints import valid_timestamp, check_utf8, \ from swift.common.constraints import valid_timestamp, check_utf8, \
check_drive, AUTO_CREATE_ACCOUNT_PREFIX check_drive, AUTO_CREATE_ACCOUNT_PREFIX
from swift.common.bufferedhttp import http_connect from swift.common.bufferedhttp import http_connect
@ -53,6 +54,7 @@ from swift.common.swob import HTTPAccepted, HTTPBadRequest, HTTPConflict, \
HTTPPreconditionFailed, HTTPMethodNotAllowed, Request, Response, \ HTTPPreconditionFailed, HTTPMethodNotAllowed, Request, Response, \
HTTPInsufficientStorage, HTTPException, HTTPMovedPermanently, \ HTTPInsufficientStorage, HTTPException, HTTPMovedPermanently, \
wsgi_to_str, str_to_wsgi wsgi_to_str, str_to_wsgi
from swift.common.wsgi import run_wsgi
def gen_resp_headers(info, is_deleted=False): def gen_resp_headers(info, is_deleted=False):
@ -1048,3 +1050,12 @@ def app_factory(global_conf, **local_conf):
conf = global_conf.copy() conf = global_conf.copy()
conf.update(local_conf) conf.update(local_conf)
return ContainerController(conf) return ContainerController(conf)
def main():
conf_file, options = parse_options(test_config=True)
sys.exit(run_wsgi(conf_file, 'container-server', **options))
if __name__ == '__main__':
main()

View File

@ -21,6 +21,7 @@ from six.moves.urllib.parse import unquote
import json import json
import os import os
import multiprocessing import multiprocessing
import sys
import time import time
import traceback import traceback
import socket import socket
@ -34,7 +35,7 @@ from swift.common.utils import public, get_logger, \
get_expirer_container, parse_mime_headers, \ get_expirer_container, parse_mime_headers, \
iter_multipart_mime_documents, extract_swift_bytes, safe_json_loads, \ iter_multipart_mime_documents, extract_swift_bytes, safe_json_loads, \
config_auto_int_value, split_path, get_redirect_data, \ config_auto_int_value, split_path, get_redirect_data, \
normalize_timestamp, md5 normalize_timestamp, md5, parse_options
from swift.common.bufferedhttp import http_connect from swift.common.bufferedhttp import http_connect
from swift.common.constraints import check_object_creation, \ from swift.common.constraints import check_object_creation, \
valid_timestamp, check_utf8, AUTO_CREATE_ACCOUNT_PREFIX valid_timestamp, check_utf8, AUTO_CREATE_ACCOUNT_PREFIX
@ -58,6 +59,7 @@ from swift.common.swob import HTTPAccepted, HTTPBadRequest, HTTPCreated, \
HTTPClientDisconnect, HTTPMethodNotAllowed, Request, Response, \ HTTPClientDisconnect, HTTPMethodNotAllowed, Request, Response, \
HTTPInsufficientStorage, HTTPForbidden, HTTPException, HTTPConflict, \ HTTPInsufficientStorage, HTTPForbidden, HTTPException, HTTPConflict, \
HTTPServerError, bytes_to_wsgi, wsgi_to_bytes, wsgi_to_str, normalize_etag HTTPServerError, bytes_to_wsgi, wsgi_to_bytes, wsgi_to_str, normalize_etag
from swift.common.wsgi import run_wsgi
from swift.obj.diskfile import RESERVED_DATAFILE_META, DiskFileRouter from swift.obj.diskfile import RESERVED_DATAFILE_META, DiskFileRouter
from swift.obj.expirer import build_task_obj, embed_expirer_bytes_in_ctype, \ from swift.obj.expirer import build_task_obj, embed_expirer_bytes_in_ctype, \
X_DELETE_TYPE X_DELETE_TYPE
@ -1454,3 +1456,14 @@ def app_factory(global_conf, **local_conf):
conf = global_conf.copy() conf = global_conf.copy()
conf.update(local_conf) conf.update(local_conf)
return ObjectController(conf) return ObjectController(conf)
def main():
conf_file, options = parse_options(test_config=True)
sys.exit(run_wsgi(conf_file, 'object-server',
global_conf_callback=global_conf_callback,
**options))
if __name__ == '__main__':
main()

View File

@ -36,7 +36,8 @@ from swift.common.utils import Watchdog, get_logger, \
get_remote_client, split_path, config_true_value, generate_trans_id, \ get_remote_client, split_path, config_true_value, generate_trans_id, \
affinity_key_function, affinity_locality_predicate, list_from_csv, \ affinity_key_function, affinity_locality_predicate, list_from_csv, \
parse_prefixed_conf, config_auto_int_value, node_to_string, \ parse_prefixed_conf, config_auto_int_value, node_to_string, \
config_request_node_count_value, config_percent_value, cap_length config_request_node_count_value, config_percent_value, cap_length, \
parse_options
from swift.common.registry import register_swift_info from swift.common.registry import register_swift_info
from swift.common.constraints import check_utf8, valid_api_version from swift.common.constraints import check_utf8, valid_api_version
from swift.proxy.controllers import AccountController, ContainerController, \ from swift.proxy.controllers import AccountController, ContainerController, \
@ -49,6 +50,7 @@ from swift.common.swob import HTTPBadRequest, HTTPForbidden, \
HTTPServerError, HTTPException, Request, HTTPServiceUnavailable, \ HTTPServerError, HTTPException, Request, HTTPServiceUnavailable, \
wsgi_to_str wsgi_to_str
from swift.common.exceptions import APIVersionError from swift.common.exceptions import APIVersionError
from swift.common.wsgi import run_wsgi
# List of entry points for mandatory middlewares. # List of entry points for mandatory middlewares.
@ -818,3 +820,12 @@ def app_factory(global_conf, **local_conf):
app = Application(conf) app = Application(conf)
app.check_config() app.check_config()
return app return app
def main():
conf_file, options = parse_options(test_config=True)
sys.exit(run_wsgi(conf_file, 'proxy-server', **options))
if __name__ == '__main__':
main()