| 824 | } |
| 825 | |
| 826 | int Server::StartInternal(const butil::EndPoint& endpoint, |
| 827 | const PortRange& port_range, |
| 828 | const ServerOptions *opt) { |
| 829 | std::unique_ptr<Server, RevertServerStatus> revert_server(this); |
| 830 | if (_failed_to_set_max_concurrency_of_method) { |
| 831 | _failed_to_set_max_concurrency_of_method = false; |
| 832 | LOG(ERROR) << "previous call to MaxConcurrencyOf() was failed, " |
| 833 | "fix it before starting server"; |
| 834 | return -1; |
| 835 | } |
| 836 | if (_failed_to_set_ignore_eovercrowded) { |
| 837 | _failed_to_set_ignore_eovercrowded = false; |
| 838 | LOG(ERROR) << "previous call to IgnoreEovercrowdedOf() was failed, " |
| 839 | "fix it before starting server"; |
| 840 | return -1; |
| 841 | } |
| 842 | if (InitializeOnce() != 0) { |
| 843 | LOG(ERROR) << "Fail to initialize Server[" << version() << ']'; |
| 844 | return -1; |
| 845 | } |
| 846 | const Status st = status(); |
| 847 | if (st != READY) { |
| 848 | if (st == RUNNING) { |
| 849 | LOG(ERROR) << "Server[" << version() << "] is already running on " |
| 850 | << _listen_addr; |
| 851 | } else { |
| 852 | LOG(ERROR) << "Can't start Server[" << version() |
| 853 | << "] which is " << status_str(status()); |
| 854 | } |
| 855 | return -1; |
| 856 | } |
| 857 | |
| 858 | copy_and_fill_server_options(_options, opt ? *opt : ServerOptions()); |
| 859 | |
| 860 | if (!_options.h2_settings.IsValid(true/*log_error*/)) { |
| 861 | LOG(ERROR) << "Invalid h2_settings"; |
| 862 | return -1; |
| 863 | } |
| 864 | |
| 865 | if (_options.bthread_tag < BTHREAD_TAG_DEFAULT || |
| 866 | _options.bthread_tag >= FLAGS_task_group_ntags) { |
| 867 | LOG(ERROR) << "Fail to set tag " << _options.bthread_tag |
| 868 | << ", tag range is [" << BTHREAD_TAG_DEFAULT << ":" |
| 869 | << FLAGS_task_group_ntags << ")"; |
| 870 | return -1; |
| 871 | } |
| 872 | int ret = TransportFactory::ContextInitOrDie(_options.socket_mode, true, &_options); |
| 873 | if (ret != 0) { |
| 874 | LOG(ERROR) << "Fail to initialize transport context for server, ret=" << ret; |
| 875 | return -1; |
| 876 | } |
| 877 | |
| 878 | if (_options.http_master_service) { |
| 879 | // Check requirements for http_master_service: |
| 880 | // has "default_method" & request/response have no fields |
| 881 | const google::protobuf::ServiceDescriptor* sd = |
| 882 | _options.http_master_service->GetDescriptor(); |
| 883 | const google::protobuf::MethodDescriptor* md = |
nothing calls this directly
no test coverage detected