Class ShellService

java.lang.Object
net.i2p.router.web.ShellService
All Implemented Interfaces:
ClientApp

public class ShellService extends Object implements ClientApp
Alternative to ShellCommand for plugins based on ProcessBuilder, which manages a process and keeps track of it's state by maintaining a Process object. Keeps track of the process, and reports start/stop status correctly on configplugins. When running a ShellService from a clients.config file, the user MUST pass -shellservice.name in the args field in clients.config to override the plugin name. The name passed to -shellservice.name should be unique to avoid causing issues. (https://i2pgit.org/i2p-hackers/i2p.i2p/-/merge_requests/39#note_4234) -shellservice.displayName is optional and configures the name of the plugin which is shown on the console. In most cases, the -shellservice.name must be the same as the plugin name in order for the $PLUGIN field in clients.config to match the expected value. If this is not the case, i.e. (-shellservice.name != plugin.name), you must not use $PLUGIN in your clients.config file. The recommended way to use this tool is to manage a single forked app/process, with a single ShellService, in a single plugin. When you are writing your clients.config file, please take note that $PLUGIN will be derived from the `shellservice.name` field in the config file args. Works on Windows, OSX, and Linux.
Since:
1.6.0/0.9.52, moved from net.i2p.app in 0.9.53
Author:
eyedeekay
  • Constructor Details

  • Method Details

    • startup

      public void startup() throws Throwable
      Determine if a ShellService corresponding to the wrapped application has been started yet. If it hasn't, attempt to start the process and notify the router that it has been started.
      Specified by:
      startup in interface ClientApp
      Throws:
      Throwable
    • isProcessStopped

      public boolean isProcessStopped()
      Determine if the process running or not.
      Returns:
      true if the Process is NOT running, false if the Process is running
    • isProcessRunning

      public boolean isProcessRunning()
      Determine if the process running or not.
      Returns:
      true if the Process is running, false if the Process is not running
    • shutdown

      public void shutdown(String[] args) throws Throwable
      Shut down the process by calling Process.destroy()
      Specified by:
      shutdown in interface ClientApp
      Parameters:
      args - generally null but could be stopArgs from clients.config
      Throws:
      Throwable
    • getState

      public ClientAppState getState()
      Query the state of managed process and determine if it is running or not. Convert to corresponding ClientAppState and return the correct value.
      Specified by:
      getState in interface ClientApp
      Returns:
      non-null
    • getName

      public String getName()
      The generic name of the ClientApp, used for registration, e.g. "console". Do not translate. Has a special use in the context of ShellService, must match the plugin name.
      Specified by:
      getName in interface ClientApp
      Returns:
      non-null
    • getDisplayName

      public String getDisplayName()
      The display name of the ClientApp, used in user interfaces. The app must translate.
      Specified by:
      getDisplayName in interface ClientApp
      Returns:
      non-null