java.lang.Object
com.aoindustries.aoserv.daemon.AoservDaemon

public final class AoservDaemon extends Object
The AoservDaemon starts all of the services that run inside the Java VM.

TODO: List AoservDaemon at http://www.firewalld.org/

Author:
AO Industries, Inc.
  • Field Details

    • DEBUG

      public static final boolean DEBUG
      See Also:
    • executorService

      public static final ExecutorService executorService
      An unbounded executor for daemon-wide tasks.
  • Method Details

    • getSecureRandom

      public static SecureRandom getSecureRandom()
      A single random number generator is shared by all daemon resources.

      Note: This is not a strong instance to avoid blocking.

    • getFastRandom

      public static Random getFastRandom()
      A fast pseudo-random number generator for non-cryptographic purposes.
    • findUnownedFiles

      public static void findUnownedFiles(File file, Collection<Integer> uids, List<File> deleteFileList, int recursionLevel) throws IOException
      Recursively searches for any files that are not owned by a UID in the provided list. If an unowned file is found and is a directory, its contents are not searched. To avoid infinite recursion, symbolic links are not followed but may be deleted.
      Parameters:
      file - the File to search from
      uids - the IntList containing the list of uids
      Throws:
      IOException
    • getConnector

      public static AoservConnector getConnector() throws ConfigurationException
      Throws:
      ConfigurationException
    • getThisServer

      public static Server getThisServer() throws IOException, SQLException
      Throws:
      IOException
      SQLException
    • main

      public static void main(String[] args)
      Runs the AoservDaemon with the values provided in com/aoindustries/aoserv/daemon/aoserv-daemon.properties. This will typically be called by the init scripts of the dedicated machine.
    • getCommandString

      public static String getCommandString(String... command)
      Gets a single-String representation of the command. This should be used for display purposes only, because it doesn't quote things in a shell-safe way.
    • execCall

      public static <V> V execCall(ConsumerE<? super OutputStream,? extends IOException> stdin, FunctionE<? super InputStream,V,? extends IOException> stdout, File workingDirectory, String... command) throws IOException
      Executes a command, performing any arbitrary action with the command's output stream. Command's input is written on the current thread. Command's output is read, and handled, on a different thread. Command's error output is also read on a different thread.

      The command's standard error is logged to System.err.

      Any non-zero exit value will result in an exception, including the standard error output when available.

      Throws:
      IOException
    • execCall

      public static <V> V execCall(ConsumerE<? super OutputStream,? extends IOException> stdin, FunctionE<? super InputStream,V,? extends IOException> stdout, String... command) throws IOException
      Executes a command, performing any arbitrary action with the command's output stream. Command's input is written on the current thread. Command's output is read, and handled, on a different thread. Command's error output is also read on a different thread.

      The command's standard error is logged to System.err.

      Any non-zero exit value will result in an exception, including the standard error output when available.

      Throws:
      IOException
    • execRun

      public static void execRun(ConsumerE<? super OutputStream,? extends IOException> stdin, ConsumerE<? super InputStream,? extends IOException> stdout, File workingDirectory, String... command) throws IOException
      Executes a command, performing any arbitrary action with the command's output stream. Command's input is written on the current thread. Command's output is read, and handled, on a different thread. Command's error output is also read on a different thread.

      The command's standard error is logged to System.err.

      Any non-zero exit value will result in an exception, including the standard error output when available.

      Throws:
      IOException
    • execRun

      public static void execRun(ConsumerE<? super OutputStream,? extends IOException> stdin, ConsumerE<? super InputStream,? extends IOException> stdout, String... command) throws IOException
      Executes a command, performing any arbitrary action with the command's output stream. Command's input is written on the current thread. Command's output is read, and handled, on a different thread. Command's error output is also read on a different thread.

      The command's standard error is logged to System.err.

      Any non-zero exit value will result in an exception, including the standard error output when available.

      Throws:
      IOException
    • execCall

      public static <V> V execCall(FunctionE<? super InputStream,V,? extends IOException> stdout, File workingDirectory, String... command) throws IOException
      Executes a command, performing any arbitrary action with the command's output stream. Command's input is opened then immediately closed. Command's output is read, and handled, on the current thread. Command's error output is read on a different thread.

      The command's standard error is logged to System.err.

      Any non-zero exit value will result in an exception, including the standard error output when available.

      Throws:
      IOException
    • execCall

      public static <V> V execCall(FunctionE<? super InputStream,V,? extends IOException> stdout, String... command) throws IOException
      Executes a command, performing any arbitrary action with the command's output stream. Command's input is opened then immediately closed. Command's output is read, and handled, on the current thread. Command's error output is read on a different thread.

      The command's standard error is logged to System.err.

      Any non-zero exit value will result in an exception, including the standard error output when available.

      Throws:
      IOException
    • execRun

      public static void execRun(ConsumerE<? super InputStream,? extends IOException> stdout, File workingDirectory, String... command) throws IOException
      Executes a command, performing any arbitrary action with the command's output stream. Command's input is opened then immediately closed. Command's output is read, and handled, on the current thread. Command's error output is read on a different thread.

      The command's standard error is logged to System.err.

      Any non-zero exit value will result in an exception, including the standard error output when available.

      Throws:
      IOException
    • execRun

      public static void execRun(ConsumerE<? super InputStream,? extends IOException> stdout, String... command) throws IOException
      Executes a command, performing any arbitrary action with the command's output stream. Command's input is opened then immediately closed. Command's output is read, and handled, on the current thread. Command's error output is read on a different thread.

      The command's standard error is logged to System.err.

      Any non-zero exit value will result in an exception, including the standard error output when available.

      Throws:
      IOException
    • exec

      public static void exec(File workingDirectory, String... command) throws IOException
      Executes a command, opens then immediately closes the command's input, and discards the output.
      Throws:
      IOException
      See Also:
    • exec

      public static void exec(String... command) throws IOException
      Executes a command, opens then immediately closes the command's input, and discards the output.
      Throws:
      IOException
      See Also:
    • execAndCapture

      public static String execAndCapture(File workingDirectory, String... command) throws IOException
      Executes a command, opens then immediately closes the command's input, and captures the output.
      Throws:
      IOException
    • execAndCapture

      public static String execAndCapture(String... command) throws IOException
      Executes a command, opens then immediately closes the command's input, and captures the output.
      Throws:
      IOException
    • execAndCaptureBytes

      public static byte[] execAndCaptureBytes(File workingDirectory, String... command) throws IOException
      Executes a command, opens then immediately closes the command's input, and captures the output.
      Throws:
      IOException
    • execAndCaptureBytes

      public static byte[] execAndCaptureBytes(String... command) throws IOException
      Executes a command, opens then immediately closes the command's input, and captures the output.
      Throws:
      IOException
    • suexec

      public static void suexec(User.Name username, File workingDirectory, String command, int nice) throws IOException
      Switches to the specified user and executes a command.
      Parameters:
      nice - a nice level passed to /bin/nice, a value of zero (0) will cause nice to not be called
      Throws:
      IOException