Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ Getting Started
Quick start:

1. Download the [latest pre-built SNAPSHOT release](https://oss.sonatype.org/content/repositories/snapshots/net/johnewart/gearman/gearman-server/) from the Sonatype snapshots repository
2. Run java -jar gearman-server-VERSION.jar
2. Run `java -jar gearman-server-VERSION.jar`
3. This will default to port 4730 and memory-only persistence, with snapshotting and the web interface listening on port 8080
4. To list avaliable options run `java -jar gearman-server-VERSION.jar --help`

If you want to use more advanced features, see the example config.yml
files in [the gearman-server sub-project](https://github.com/johnewart/gearman-java/tree/master/gearman-server)
If you want to use more advanced features, run server with config file `java -jar gearman-server-VERSION.jar -c path_to_config_file`.
For details check example configuration files in [the gearman-server sub-project](https://github.com/johnewart/gearman-java/tree/master/gearman-server)


Web Interface
Expand Down
10 changes: 10 additions & 0 deletions cfg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
port: 4730
httpPort: 8888
enableSSL: false
debugging: false
hostName: gearman
persistenceEngine:
engine: memory
exceptionStore:
engine: memory
logLevel: WARN
2 changes: 1 addition & 1 deletion gearman-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>gearman-java</artifactId>
<groupId>net.johnewart.gearman</groupId>
<version>0.8.11-SNAPSHOT</version>
<version>0.8.12-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion gearman-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>gearman-java</artifactId>
<groupId>net.johnewart.gearman</groupId>
<version>0.8.11-SNAPSHOT</version>
<version>0.8.12-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion gearman-embedded-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>gearman-java</artifactId>
<groupId>net.johnewart.gearman</groupId>
<version>0.8.11-SNAPSHOT</version>
<version>0.8.12-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion gearman-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>gearman-java</artifactId>
<groupId>net.johnewart.gearman</groupId>
<version>0.8.11-SNAPSHOT</version>
<version>0.8.12-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion gearman-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>gearman-java</artifactId>
<groupId>net.johnewart.gearman</groupId>
<version>0.8.11-SNAPSHOT</version>
<version>0.8.12-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion gearman-integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>gearman-java</artifactId>
<groupId>net.johnewart.gearman</groupId>
<version>0.8.11-SNAPSHOT</version>
<version>0.8.12-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
7 changes: 6 additions & 1 deletion gearman-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>gearman-java</artifactId>
<groupId>net.johnewart.gearman</groupId>
<version>0.8.11-SNAPSHOT</version>
<version>0.8.12-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gearman-server</artifactId>
Expand All @@ -27,6 +27,11 @@
<artifactId>snakeyaml</artifactId>
<version>1.12</version>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.72</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package net.johnewart.gearman.server;

import com.beust.jcommander.JCommander;
import com.beust.jcommander.ParameterException;
import net.johnewart.gearman.server.config.DefaultServerConfiguration;
import net.johnewart.gearman.server.config.GearmanServerConfiguration;
import net.johnewart.gearman.server.net.ServerListener;
import net.johnewart.gearman.server.web.WebListener;
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.Yaml;
import com.beust.jcommander.Parameter;

import java.io.InputStream;
import java.nio.file.Files;
Expand All @@ -14,18 +17,37 @@
public class GearmanDaemon {
private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(GearmanDaemon.class);

private static class CommandLineOptions {
@Parameter(names = {"--debug", "-d"}, description = "Turn on debug mode, resulting in a more verbose log output")
boolean debug = false;

@Parameter(names = {"--config", "-c"}, description = "Specify file to load configuration")
String configFile;

@Parameter(names = {"--help", "-h"}, description = "Prints usage", help = true)
boolean help;
}

public static void main(String... args)
{
final String configFile;
CommandLineOptions options = new CommandLineOptions();
JCommander cmd = new JCommander(options);
cmd.setProgramName("Gearman Server");

if (args.length != 1) {
configFile = "config.yml";
} else {
configFile = args[0];
try {
cmd.parse(args);
if(options.help) {
cmd.usage();
System.exit(0);
}

} catch (ParameterException e) {
cmd.usage();
System.exit(0);
}


final GearmanServerConfiguration serverConfiguration = loadFromConfigOrGenerateDefaultConfig(configFile);
final GearmanServerConfiguration serverConfiguration = loadFromConfigOrGenerateDefaultConfig(options.configFile);
serverConfiguration.setDebugging(options.debug);
final ServerListener serverListener = new ServerListener(serverConfiguration);
final WebListener webListener = new WebListener(serverConfiguration);

Expand All @@ -44,10 +66,8 @@ private static GearmanServerConfiguration loadFromConfigOrGenerateDefaultConfig(

serverConfiguration
= yaml.loadAs(in, GearmanServerConfiguration.class);

System.out.println(serverConfiguration.toString());

LOG.info("Starting Gearman Server with settings from " + configFile + "...");
LOG.info("Serveer settings: " + serverConfiguration.toString());

} catch (Exception e) {
LOG.error("Can't load " + configFile + ": ", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public class GearmanServerConfiguration implements ServerConfiguration {
private MetricRegistry metricRegistry;
private QueueMetrics queueMetrics;
private HealthCheckRegistry healthCheckRegistry;
private Object configLock = new Object();
private final Object configLock = new Object();
private String logLevel = "ERROR";

public void setPort(int port) {
this.port = port;
Expand All @@ -61,15 +62,20 @@ public void setEnableSSL(boolean enableSSL) {
this.enableSSL = enableSSL;
}

public void setLogLevel(String logLevel){
this.logLevel = logLevel;
if(!debugging) {
Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
root.setLevel(Level.toLevel(this.logLevel));
}
}

public void setDebugging(boolean debugging) {
this.debugging = debugging;

Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
if(debugging)
{
if(debugging) {
root.setLevel(Level.DEBUG);
} else {
root.setLevel(Level.ERROR);
}
}

Expand Down Expand Up @@ -147,10 +153,10 @@ public JobQueueFactory getJobQueueFactory() {
public JobManager getJobManager() {
if(jobManager == null) {
jobManager = new JobManager(getJobQueueFactory(),
getJobHandleFactory(),
getUniqueIdFactory(),
getExceptionStorageEngine(),
getQueueMetrics());
getJobHandleFactory(),
getUniqueIdFactory(),
getExceptionStorageEngine(),
getQueueMetrics());
}

return jobManager;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>net.johnewart.gearman</groupId>
<artifactId>gearman-java</artifactId>
<packaging>pom</packaging>
<version>0.8.11-SNAPSHOT</version>
<version>0.8.12-SNAPSHOT</version>
<modules>
<module>gearman-client</module>
<module>gearman-server</module>
Expand Down