public class Daemon
extends java.lang.Object
implements java.lang.Runnable
Daemon()
Modifier and Type | Class and Description |
---|---|
static interface |
Daemon.ComListener
Receives COM port data.
|
static class |
Daemon.ComPort
COM port.
|
static interface |
Daemon.DNSListener
So that you can hot-deploy your DNS solution.
|
static interface |
Daemon.ErrListener
Error listener, so you can for example send a warning mail and swallow
certain exceptions to not be logged.
|
static interface |
Daemon.JVMListener
Cross class-loader communication interface.
|
class |
Daemon.Lock |
static class |
Daemon.SPIData
SPI data.
|
static interface |
Daemon.SPIListener
Receives SPI interrupt.
|
static interface |
Daemon.UDPListener
Cross cluster-node communication interface.
|
Constructor and Description |
---|
Daemon()
Don't forget to call
start() . |
Daemon(java.util.Properties properties)
Don't forget to call
start() . |
Modifier and Type | Method and Description |
---|---|
void |
add(Daemon.UDPListener listener)
Add multicast listener.
|
void |
add(Service service)
You can only add services manually in unhosted mode.
|
Deploy.Archive |
archive(java.lang.String name,
boolean deployer) |
java.lang.String |
bind() |
void |
broadcast(byte[] tail)
Send inter-cluster-node UDP multicast message.
|
Daemon.Lock |
chain(Event event,
java.lang.String path) |
Async |
client() |
Daemon.ComPort |
com()
To get the COM port.
|
java.lang.String |
domain() |
Event |
event(int id)
Disabled for hosted mode.
|
static Daemon |
init(java.lang.String[] args)
To use your own main method if you for example need COM port handling.
|
static void |
main(java.lang.String[] args) |
se.rupy.http.Daemon.Metric |
metric(java.lang.String name) |
java.lang.String |
name() |
int |
online() |
static void |
premain(java.lang.String agentArgs,
java.lang.instrument.Instrumentation inst) |
java.util.Properties |
properties() |
void |
remove(Daemon.UDPListener listener)
Remove multicast listener.
|
void |
run() |
java.lang.Object |
send(Event event,
java.lang.Object message)
Send Object to JVM listener.
|
void |
set(Daemon.ComPort com)
To use the COM interface you should boot rupy with your own main method.
|
boolean |
set(Daemon.DNSListener dns)
Set the host controller as DNS server.
|
boolean |
set(Daemon.ErrListener err)
Listens for errors.
|
boolean |
set(Daemon.JVMListener listener)
Intra JVM many-to-one listener.
|
void |
set(Daemon.SPIData spi,
int channel)
To use the SPI interface you should boot rupy with your own main method.
|
Daemon.SPIData |
spi(int channel)
To get the SPI data channel.
|
void |
start()
Starts the selector, heartbeat and worker threads.
|
void |
stop()
Stops the selector, heartbeat and worker threads.
|
public Daemon()
start()
.public Daemon(java.util.Properties properties)
start()
. You can also use init(String[])
which will parse
the parameters for you. The parameters below should be in the properties argument. The parenthesis
contains the default value.pass () |
the pass used to deploy services with Deploy via HTTP POST,
default is '' which disables hot-deploy; pass 'secret' only allows
deploys from 127.0.0.1.
|
port (8000) | which TCP port. |
threads (5) | how many worker threads, the daemon also starts one selector and one heartbeat thread. |
timeout (300) | session timeout in seconds or 0 to disable sessions |
cookie (4) | session key character length; default and minimum is 4, > 10 can be considered secure. |
delay (5000) | milliseconds before started event gets dropped due to inactivity. This is also the dead socket worker cleanup variable, so if a worker has a socket that hasn't been active for longer than this; the worker will be released and the socket deemed as dead. |
size (1024) | IO buffer size in bytes, should be proportional to the data sizes received/sent by the server currently this is input/output- buffer, chunk-buffer, post-body-max and header-max lengths! :P |
live (false) | is this rupy running live. |
cache (86400) requires live | seconds to hard cache static files. |
verbose (false) | to log information about these startup parameters, high-level info for each request and deployed services overview. |
debug (false) | to log low-level NIO info for each request and class loading info. |
log (false) | simple log of access and error in /log. |
bind () | to bind to a specific ip. |
async_timeout (1000) | timeout for the async client in milliseconds. |
host (false) |
to enable virtual hosting, you need to name the deployment
jars [host].jar, for example: host.rupy.se.jar.
Also if you want to deploy root domain, just deploy www.[host];
so for example www.rupy.se.jar will trigger http://rupy.se.
To authenticate deployments you should use a properties file
called passport in the rupy root where you store [host]=[pass]. if your host is a PaaS on one machine; add -Djava.security.manager -Djava.security.policy=policy to the rupy java process, add the passport file to your control domain app folder instead (for example app/host.rupy.se/passport; hide it from downloading with the code below) and create a symbolic link to that in the rupy root. public static class Secure extends Service { public String path() { return "/passport"; } public void filter(Event event) throws Event, Exception { event.output().print("Nice try!"); } } |
domain (host.rupy.se) requires host |
if you are hosting a PaaS
across a cluster, you have to hook your control domain app up with
set(JVMListener listener) . And reply "OK" if the "auth" message authenticates with Deploy.hash(File file, String pass, String cookie) :
{"type": "auth", "file": "[host].jar", "pass": "[pass]", "cookie": "[salt]", "cluster": [true/false]} Then you can propagate the deploy with Deploy.deploy(String host, File file, String pass)
if "cluster" is "false" in a separate thread. But for that to work you also need to answer this
message with "OK" for your known individual cluster hosts:
{"type": "host", "file": "[name]"} Where [name] is your.domain.name.jar. For example I have two hosts: one.rupy.se and two.rupy.se that belong under host.rupy.se so I need to return "OK" if any of these two specific domains try to deploy. |
multi (false) |
UDP multicast to all cluster nodes for real-time sync. But for this to work you also need to answer this
message with "OK" for your known individual cluster ips:
{"type": "packet", "from": "[ip]"} |
root (false) | Root is a distributed index of JSON objects and graph of their relationships in the filesystem. It supports full text search but has rough naming conventions and no order guarantee, it's a work in progress. |
public java.lang.String bind()
public java.lang.String domain()
public static void premain(java.lang.String agentArgs, java.lang.instrument.Instrumentation inst)
public Async client() throws java.lang.Exception
java.lang.Exception
public Event event(int id)
id
- public java.lang.String name()
public java.util.Properties properties()
public void start()
public void stop()
public int online()
public se.rupy.http.Daemon.Metric metric(java.lang.String name)
public Deploy.Archive archive(java.lang.String name, boolean deployer)
public java.lang.Object send(Event event, java.lang.Object message) throws java.lang.Exception
event
- if applicable attach eventmessage
- to sendjava.lang.Exception
public boolean set(Daemon.JVMListener listener)
listener
- public boolean set(Daemon.DNSListener dns)
dns
- public Daemon.ComPort com()
public void set(Daemon.ComPort com)
init(String[])
from there to be able to use this method.
Don't forget to call start()
after you used this method.com
- public Daemon.SPIData spi(int channel)
public void set(Daemon.SPIData spi, int channel)
init(String[])
from there to be able to use this method.
Don't forget to call start()
after you used this method.spi
- public boolean set(Daemon.ErrListener err)
err
- public void broadcast(byte[] tail) throws java.lang.Exception
tail
- your payload.
Max length is 1024 bytes including header: [host].[node]!java.lang.Exception
public void add(Daemon.UDPListener listener)
listener
- public void remove(Daemon.UDPListener listener)
listener
- public void add(Service service) throws java.lang.Exception
service
- java.lang.Exception
public Daemon.Lock chain(Event event, java.lang.String path)
public void run()
run
in interface java.lang.Runnable
public static Daemon init(java.lang.String[] args)
start()
after you called set(ComPort)
.args
- public static void main(java.lang.String[] args)