315748 Removed --fromDaemon from start.jar

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1919 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2010-06-04 11:02:16 +00:00
parent 78587f820c
commit b3c156a988
7 changed files with 29 additions and 320 deletions

View File

@ -10,6 +10,7 @@ jetty-7.1.4-SNAPSHOT
+ 315190 CrossOriginFilter adds headers not understood by Chrome 5 WebSocket implementation
+ 315715 Improved Cookie version handling. Server.setMaxCookieVersion
+ 315744 Fixed STOP.PORT and STOP.KEY in start.jar
+ 315748 Removed --fromDaemon from start.jar
jetty-7.1.3.v20100526
+ 296567 HttpClient RedirectListener handles new HttpDestination

View File

@ -121,9 +121,6 @@ readConfig()
##################################################
# Get the action & configs
##################################################
@ -270,6 +267,10 @@ if [ -z "$CONFIGS" ] && [ -f "$JETTY_CONF" ] && [ -r "$JETTY_CONF" ]
then
while read -r CONF
do
if expr "$CONF" : '^#' >/dev/null ; then
continue
fi
if [ ! -r "$CONF" ]
then
echo "** WARNING: Cannot read '$CONF' specified in '$JETTY_CONF'"
@ -371,7 +372,7 @@ fi
##################################################
# Determine which JVM of version >1.2
# Determine which JVM of version >1.5
# Try to use JAVA_HOME
##################################################
if [ -z "$JAVA" ] && [ "$JAVA_HOME" ]
@ -387,7 +388,7 @@ fi
if [ -z "$JAVA" ]
then
echo "Cannot find a JRE or JDK. Please set JAVA_HOME to a >=1.2 JRE" 2>&2
echo "Cannot find a JRE or JDK. Please set JAVA_HOME to a >=1.5 JRE" 2>&2
exit 1
fi
@ -433,7 +434,10 @@ JAVA_OPTIONS+=("-Djetty.home=$JETTY_HOME" "-Djava.io.tmpdir=$TMPDIR")
JETTY_START=$JETTY_HOME/start.jar
[ ! -f "$JETTY_START" ] && JETTY_START=$JETTY_HOME/lib/start.jar
RUN_ARGS=("${JAVA_OPTIONS[@]}" -jar "$JETTY_START" --fromDaemon $JETTY_ARGS "${CONFIGS[@]}")
START_INI=$(dirname $JETTY_START)/start.ini
[ -r "$START_INI" ] || START_INI=""
RUN_ARGS=("${JAVA_OPTIONS[@]}" -jar "$JETTY_START" $JETTY_ARGS "${CONFIGS[@]}")
RUN_CMD=("$JAVA" "${RUN_ARGS[@]}")
#####################################################
@ -600,6 +604,7 @@ case "$ACTION" in
echo "JETTY_PID = $JETTY_PID"
echo "JETTY_PORT = $JETTY_PORT"
echo "JETTY_LOGS = $JETTY_LOGS"
echo "START_INI = $START_INI"
echo "CONFIGS = ${CONFIGS[*]}"
echo "JAVA_OPTIONS = ${JAVA_OPTIONS[*]}"
echo "JAVA = $JAVA"

View File

@ -0,0 +1,13 @@
# ========================================================
# jetty.conf Configuration for jetty.sh script
# --------------------------------------------------------
# This file is used by the jetty.sh script to provide
# extra configuration arguments for the start.jar command
# created by that script.
#
# Each line in this file becomes an arguement to start.jar
# unless this file contains an --ini option, then these
# arguments will be in addition to those found in the
# start.ini file
# =======================================================
etc/jetty-logging.xml

View File

@ -38,7 +38,6 @@ import java.util.List;
import java.util.Set;
import java.util.TimeZone;
import org.eclipse.jetty.start.log.RedirectedStreamLogger;
/*-------------------------------------------*/
/**
@ -61,7 +60,6 @@ public class Main
private boolean _dryRun = false;
private boolean _exec = false;
private boolean _secure = false;
private boolean _fromDaemon = false;
private final Config _config = new Config();
private Set<String> _sysProps = new HashSet<String>();
private List<String> _jvmArgs = new ArrayList<String>();
@ -167,10 +165,7 @@ public class Main
// Special internal indicator that jetty was started by the jetty.sh Daemon
if ("--fromDaemon".equals(arg))
{
_fromDaemon = true;
PrintStream logger = new PrintStream(new RedirectedStreamLogger("daemon_yyyy_mm_dd.log",false,90,TimeZone.getTimeZone("GMT")));
System.setOut(logger);
System.setErr(logger);
System.err.println("WARN: Ignored deprecated --fromDaemon");
continue;
}
@ -496,12 +491,6 @@ public class Main
throw new FileNotFoundException("No XML configuration files specified in start.config or command line.");
}
// Add required logging if executed via the daemon.
if (_fromDaemon)
{
configuredXmls.add("etc/jetty-logging.xml");
}
// Add mandatory options for secure mode
if (_secure)
{

View File

@ -1,299 +0,0 @@
package org.eclipse.jetty.start.log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import java.util.Timer;
import java.util.TimerTask;
public class RedirectedStreamLogger extends FilterOutputStream
{
private static Timer __rollover;
final static String YYYY_MM_DD = "yyyy_mm_dd";
final static String ROLLOVER_FILE_DATE_FORMAT = "yyyy_MM_dd";
final static String ROLLOVER_FILE_BACKUP_FORMAT = "HHmmssSSS";
final static int ROLLOVER_FILE_RETAIN_DAYS = 31;
private RollTask _rollTask;
private SimpleDateFormat _fileBackupFormat;
private SimpleDateFormat _fileDateFormat;
private String _filename;
private File _file;
private boolean _append;
private int _retainDays;
/* ------------------------------------------------------------ */
/**
* @param filename
* The filename must include the string "yyyy_mm_dd", which is replaced with the actual date when
* creating and rolling over the file.
* @throws IOException
*/
public RedirectedStreamLogger(String filename) throws IOException
{
this(filename,true,ROLLOVER_FILE_RETAIN_DAYS);
}
/* ------------------------------------------------------------ */
/**
* @param filename
* The filename must include the string "yyyy_mm_dd", which is replaced with the actual date when
* creating and rolling over the file.
* @param append
* If true, existing files will be appended to.
* @throws IOException
*/
public RedirectedStreamLogger(String filename, boolean append) throws IOException
{
this(filename,append,ROLLOVER_FILE_RETAIN_DAYS);
}
/* ------------------------------------------------------------ */
/**
* @param filename
* The filename must include the string "yyyy_mm_dd", which is replaced with the actual date when
* creating and rolling over the file.
* @param append
* If true, existing files will be appended to.
* @param retainDays
* The number of days to retain files before deleting them. 0 to retain forever.
* @throws IOException
*/
public RedirectedStreamLogger(String filename, boolean append, int retainDays) throws IOException
{
this(filename,append,retainDays,TimeZone.getDefault());
}
/* ------------------------------------------------------------ */
/**
* @param filename
* The filename must include the string "yyyy_mm_dd", which is replaced with the actual date when
* creating and rolling over the file.
* @param append
* If true, existing files will be appended to.
* @param retainDays
* The number of days to retain files before deleting them. 0 to retain forever.
* @throws IOException
*/
public RedirectedStreamLogger(String filename, boolean append, int retainDays, TimeZone zone) throws IOException
{
this(filename,append,retainDays,zone,null,null);
}
/* ------------------------------------------------------------ */
/**
* @param filename
* The filename must include the string "yyyy_mm_dd", which is replaced with the actual date when
* creating and rolling over the file.
* @param append
* If true, existing files will be appended to.
* @param retainDays
* The number of days to retain files before deleting them. 0 to retain forever.
* @param dateFormat
* The format for the date file substitution. The default is "yyyy_MM_dd".
* @param backupFormat
* The format for the file extension of backup files. The default is "HHmmssSSS".
* @throws IOException
*/
public RedirectedStreamLogger(String filename, boolean append, int retainDays, TimeZone zone, String dateFormat, String backupFormat) throws IOException
{
super(null);
if (dateFormat == null)
dateFormat = ROLLOVER_FILE_DATE_FORMAT;
_fileDateFormat = new SimpleDateFormat(dateFormat);
if (backupFormat == null)
backupFormat = ROLLOVER_FILE_BACKUP_FORMAT;
_fileBackupFormat = new SimpleDateFormat(backupFormat);
_fileBackupFormat.setTimeZone(zone);
_fileDateFormat.setTimeZone(zone);
if (filename != null)
{
filename = filename.trim();
if (filename.length() == 0)
filename = null;
}
if (filename == null)
throw new IllegalArgumentException("Invalid filename");
_filename = filename;
_append = append;
_retainDays = retainDays;
setFile();
synchronized (RedirectedStreamLogger.class)
{
if (__rollover == null)
__rollover = new Timer(RedirectedStreamLogger.class.getName(),true);
_rollTask = new RollTask();
Calendar now = Calendar.getInstance();
now.setTimeZone(zone);
GregorianCalendar midnight = new GregorianCalendar(now.get(Calendar.YEAR),now.get(Calendar.MONTH),now.get(Calendar.DAY_OF_MONTH),23,0);
midnight.setTimeZone(zone);
midnight.add(Calendar.HOUR,1);
__rollover.scheduleAtFixedRate(_rollTask,midnight.getTime(),1000L * 60 * 60 * 24);
}
}
/* ------------------------------------------------------------ */
public String getFilename()
{
return _filename;
}
/* ------------------------------------------------------------ */
public String getDatedFilename()
{
if (_file == null)
return null;
return _file.toString();
}
/* ------------------------------------------------------------ */
public int getRetainDays()
{
return _retainDays;
}
/* ------------------------------------------------------------ */
private synchronized void setFile() throws IOException
{
// Check directory
File file = new File(_filename);
_filename = file.getCanonicalPath();
file = new File(_filename);
File dir = new File(file.getParent());
if (!dir.isDirectory() || !dir.canWrite())
throw new IOException("Cannot write log directory " + dir);
Date now = new Date();
// Is this a rollover file?
String filename = file.getName();
int i = filename.toLowerCase().indexOf(YYYY_MM_DD);
if (i >= 0)
{
file = new File(dir,filename.substring(0,i) + _fileDateFormat.format(now) + filename.substring(i + YYYY_MM_DD.length()));
}
if (file.exists() && !file.canWrite())
throw new IOException("Cannot write log file " + file);
// Do we need to change the output stream?
if (out == null || !file.equals(_file))
{
// Yep
_file = file;
if (!_append && file.exists())
file.renameTo(new File(file.toString() + "." + _fileBackupFormat.format(now)));
OutputStream oldOut = out;
out = new FileOutputStream(file.toString(),_append);
if (oldOut != null)
oldOut.close();
//if(log.isDebugEnabled())log.debug("Opened "+_file);
}
}
/* ------------------------------------------------------------ */
private void removeOldFiles()
{
if (_retainDays > 0)
{
long now = System.currentTimeMillis();
File file = new File(_filename);
File dir = new File(file.getParent());
String fn = file.getName();
int s = fn.toLowerCase().indexOf(YYYY_MM_DD);
if (s < 0)
return;
String prefix = fn.substring(0,s);
String suffix = fn.substring(s + YYYY_MM_DD.length());
String[] logList = dir.list();
for (int i = 0; i < logList.length; i++)
{
fn = logList[i];
if (fn.startsWith(prefix) && fn.indexOf(suffix,prefix.length()) >= 0)
{
File f = new File(dir,fn);
long date = f.lastModified();
if (((now - date) / (1000 * 60 * 60 * 24)) > _retainDays)
f.delete();
}
}
}
}
/* ------------------------------------------------------------ */
@Override
public void write(byte[] buf) throws IOException
{
out.write(buf);
}
/* ------------------------------------------------------------ */
@Override
public void write(byte[] buf, int off, int len) throws IOException
{
out.write(buf,off,len);
}
/* ------------------------------------------------------------ */
/**
*/
@Override
public void close() throws IOException
{
synchronized (RedirectedStreamLogger.class)
{
try
{
super.close();
}
finally
{
out = null;
_file = null;
}
_rollTask.cancel();
}
}
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
private class RollTask extends TimerTask
{
@Override
public void run()
{
try
{
RedirectedStreamLogger.this.setFile();
RedirectedStreamLogger.this.removeOldFiles();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}

View File

@ -22,7 +22,7 @@
</Arg>
</New>
<Call class="org.eclipse.jetty.util.log.Log" name="info"><Arg>Redirecting stderr/stdout to <Ref id="ServerLogName"/></Arg></Call>
<Call class="org.eclipse.jetty.util.log.Log" name="debug"><Arg>Redirecting stderr/stdout to <Ref id="ServerLogName"/></Arg></Call>
<Call class="java.lang.System" name="setErr"><Arg><Ref id="ServerLog"/></Arg></Call>
<Call class="java.lang.System" name="setOut"><Arg><Ref id="ServerLog"/></Arg></Call>

View File

@ -77,7 +77,7 @@ public class Log
if (__log == null || !__log.getClass().equals(log_class))
{
__log = (Logger)log_class.newInstance();
__log.info("Logging to {} via {}", __log, log_class.getName());
__log.debug("Logging to {} via {}", __log, log_class.getName());
}
}
catch(NoClassDefFoundError e)
@ -101,7 +101,7 @@ public class Log
{
log_class = StdErrLog.class;
__log = new StdErrLog();
__log.info("Logging to {} via {}", __log, log_class.getName());
__log.debug("Logging to {} via {}", __log, log_class.getName());
}
}