feat: worker starter use new port config name

This commit is contained in:
tjq 2023-01-22 16:38:05 +08:00
parent 789bcb5d10
commit afdf4a7dc2
3 changed files with 16 additions and 6 deletions

View File

@ -3,8 +3,8 @@ spring.jpa.open-in-view=false
########### PowerJob-worker properties. ########### ########### PowerJob-worker properties. ###########
# Whether to enable PowerJob Worker, default is true # Whether to enable PowerJob Worker, default is true
powerjob.worker.enabled=true powerjob.worker.enabled=true
# Akka port, default is 27777 # Transport port, default is 27777
powerjob.worker.akka-port=27777 powerjob.worker.port=27777
# Application name, used for grouping applications. Recommend to set the same value as project name. # Application name, used for grouping applications. Recommend to set the same value as project name.
powerjob.worker.app-name=powerjob-worker-samples powerjob.worker.app-name=powerjob-worker-samples
# Address of PowerJob-server node(s). Ip:port or domain. Multiple addresses should be separated with comma. # Address of PowerJob-server node(s). Ip:port or domain. Multiple addresses should be separated with comma.

View File

@ -46,11 +46,15 @@ public class PowerJobAutoConfiguration {
/* /*
* Configuration of worker port. Random port is enabled when port is set with non-positive number. * Configuration of worker port. Random port is enabled when port is set with non-positive number.
*/ */
int port = worker.getAkkaPort(); if (worker.getPort() != null) {
if (port <= 0) { config.setPort(worker.getPort());
port = NetUtils.getRandomPort(); } else {
int port = worker.getAkkaPort();
if (port <= 0) {
port = NetUtils.getRandomPort();
}
config.setPort(port);
} }
config.setPort(port);
/* /*
* appName, name of the application. Applications should be registered in advance to prevent * appName, name of the application. Applications should be registered in advance to prevent
* error. This property should be the same with what you entered for appName when getting * error. This property should be the same with what you entered for appName when getting

View File

@ -112,8 +112,14 @@ public class PowerJobProperties {
/** /**
* Akka port of Powerjob-worker, optional value. Default value of this property is 27777. * Akka port of Powerjob-worker, optional value. Default value of this property is 27777.
* If multiple PowerJob-worker nodes were deployed, different, unique ports should be assigned. * If multiple PowerJob-worker nodes were deployed, different, unique ports should be assigned.
* Deprecated, please use 'port'
*/ */
@Deprecated
private int akkaPort = RemoteConstant.DEFAULT_WORKER_PORT; private int akkaPort = RemoteConstant.DEFAULT_WORKER_PORT;
/**
* port
*/
private Integer port;
/** /**
* Address(es) of Powerjob-server node(s). Ip:port or domain. * Address(es) of Powerjob-server node(s). Ip:port or domain.
* Example of single Powerjob-server node: * Example of single Powerjob-server node: