Prudence
The Scalable REST/JVM
Web Development Platform

Creative Commons License

Prudence As a Daemon

Prudence comes with built-in support Apache Commons Daemon. However, in production environments, you might prefer to use one of the daemon wrappers, which provide process monitoring and control. For example, if Prudence's JVM crashes for some reason, hangs, grabs too much CPU or RAM, the wrapper can automatically shut it down and even restart it.
Though Prudence comes with the necessary configuration files for wrappers, it does not include the actual wrappers, which you will need to install separately. The reason we haven't included them is different for each wrapper: Tanuki's JSW uses a restrictive license (GPL) that will not allow us to distribute it with Prudence, and YAJSW is just far too big.

Apache Commons Daemon

The /bin/ scripts allow you to "start", "stop", "restart" and check the running "status" for the Prudence daemon (called a "service" in Windows). The daemon will write its log to "/logs/run.log".
Though you need root privileges (sudo) to start or stop the daemon, the daemon itself will attempt to run under user "prudence-X", where "X" is the name of the flavor you are using. For example, "prudence-python" is used for the Python flavor. If that user doesn't exist, the daemon will run under your user.
In any case, it's up to you to make sure that the daemon's user has the necessary read and write privileges for the Prudence files. In particular, it needs to be able to write to /logs/ and to /cache/.
The scripts work by detecting your running environment and attempting to use the appropriate Apache Commons Daemon binary. Prudence comes with binaries for Linux, Solaris, Darwin (OS X) and Windows, for both 32bit and 64bit architectures. For the script to work, the binaries need to be executable (chmod +x).

Notes for Linux

  • We maintain a repository for Ubuntu where everything just works.
  • The /bin/run.sh script can be installed as an /etc/init.d/ script, so it can also be run via Upstart, like so:
    sudo service prudence-X start
    
  • If you get an error about a missing JAVA_HOME, you can set it like so:
    sudo JAVA_HOME=/var/lib/jvm bin/run.sh start
    
  • Newer Linux operating systems might give you an error about a missing "libcap.so.1" library. In such cases, you will need to install your operating system's Apache Commons Daemon package. In Ubuntu, for example, it is package "jsvc". The /bin/run.sh script will always try to use your operating system's jsvc before falling back to the binary that comes with Prudence.

Notes for Windows

  • You need to "install" the service before you can "start" it. Use "uninstall" if you need to remove it.
  • Note that Windows requires your service executable (in the /commons-daemon/ subdirectory) to be on a local drive. It will fail on network drives.
  • Prudence is installed as a standard Windows service, so you can also use Control Panel > Administrative Tools > Services or the "net" command line tool to start and stop it. For example:
    net start PrudenceX
    
  • You can edit the settings using "settings".
  • Windows does not support "status", but you can use "monitor" to add a nice little tray icon that lets you manage the daemon.

JSW

JSW is written in C rather than Java, making it much more lightweight than YAJSW. It supports many operating systems.
See /configuration/wrapper.conf for a sample JSW configuration, which also configures the wrapper to log to /logs/wrapper.log.
In particular, you'll want to set the following configuration settings:
  • wrapper.working.dir: Set this to your Prudence installation's base directory
  • wrapper.java.command: Set this to the JVM runtime (the "java" command) you'll want to use for Prudence
  • wrapper.java.maxmemory: Set this according to your deployment environment. More memory translates to better performance, and more room for the in-process memory cache.
  • wrapper.java.initmemory: A reasonably high value here can help speed up Prudence's startup time.
The copyright for JSW is held by its original developer, Tanuki Software. For the first few versions Tanuki released JSW under a permissive license, making it popular in many open source projects. However, since version 3.2 it has been distributed under the GPL 2.0 (and also via a commercial license). We applaud Tanuki's commitment to open source, and are big fans of the GPL. However, the GPL makes it impossible to distribute JSW with open source projects using less restrictive licenses, such as Prudence. Many projects have kept distributing version 3.2 of JSW, which is now out of date and missing bug fixes. Note that Prudence's license, the LGPL 3.0, has a clause allowing you to upgrade it to GPL, which would allow you to distribute JSW with it. Doing this would in turn require you to distribute you own product under the GPL.

YAJSW

YAJSW is written in 100% Java, using JNA to handle the native operating-system-dependent features.
See /configuration/yajsw.conf for a sample JAJSW configuration. The wrapper will log to /logs/yajsw.log.
Change yasjw.conf in the same way as described for wrapper.conf, above.