我在Heroku上部署了具有Spark框架的应用程序。它是在Heroku上成功构建的,并且服务器已启动,但是当我尝试从服务器获取响应时,收到HTTP 503,并且在日志中出现以下H14错误:
private void loginUser(String email, String password) {
if (TextUtils.isEmpty(email)) {
Toast.makeText(this, "Email cannot be null or empty", Toast.LENGTH_SHORT).show();
return;
}
if (TextUtils.isEmpty(password)) {
Toast.makeText(this, "Password cannot be null or empty", Toast.LENGTH_SHORT).show();
return;
}
compositeDisposable.add(iMyService.loginUser(email, password)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<String>() {
@Override
public void accept(String response) throws Exception {
Intent i = new Intent(LoginActivity.this, MainActivity.class);
Toast.makeText(LoginActivity.this, "" + response, Toast.LENGTH_SHORT).show();
if (response.equals("Login success")) {
// Log.d("myTag", "Login Success");
startActivity(i);
}
}
})
);
}
我的2019-03-10T17:52:44.983359+00:00 heroku[servergossip.1]: Restarting
2019-03-10T17:52:45.299269+00:00 heroku[servergossip.1]: State changed from up to starting
2019-03-10T17:52:46.338372+00:00 heroku[servergossip.1]: Stopping all processes with SIGTERM
2019-03-10T17:52:46.000000+00:00 app[api]: Build succeeded
2019-03-10T17:52:46.769383+00:00 heroku[servergossip.1]: Process exited with status 143
2019-03-10T17:52:48.416183+00:00 heroku[servergossip.1]: Starting process with command `java $JAVA_OPTS -cp target/classes:target/dependency/* Main --port 37274`
2019-03-10T17:52:49.054556+00:00 heroku[servergossip.1]: State changed from starting to up
2019-03-10T17:52:51.513243+00:00 app[servergossip.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
...
2019-03-10T17:52:52.672327+00:00 app[servergossip.1]: INFO: Started ServerConnector@3ee6bd4d{HTTP/1.1}{0.0.0.0:37274}
2019-03-10T17:53:09.078587+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/bot" host=servergossip.herokuapp.com request_id=45e0301a-3c82-495e-830d-2db0b0d1f9ef fwd="87.240.189.18" dyno= connect= service= status=503 bytes= protocol=https
文件:
Procfile
Spark示例中的代码:
servergossip: java $JAVA_OPTS -cp target/classes:target/dependency/* Main --port $PORT
我使用了public class Main {
private static final Logger LOG = LoggerFactory.getLogger(Main.class);
public static void main(String[] args) {
port(getHerokuAssignedPort());
get("/bot", (req, res) -> {
return "hi";
});
}
static int getHerokuAssignedPort() {
ProcessBuilder processBuilder = new ProcessBuilder();
if (processBuilder.environment().get("PORT") != null) {
return Integer.parseInt(processBuilder.environment().get("PORT"));
}
return 4567;
}
}
之类的命令,但没有任何反应。
那怎么了?
答案 0 :(得分:1)
您的Procfile
当前定义了一个名为servergossip
的进程类型。那没有多大意义。将其更改为web
进程:
web: java $JAVA_OPTS -cp target/classes:target/dependency/* Main --port $PORT