This repository has been archived by the owner on Sep 18, 2021. It is now read-only.
forked from fizx/scala-bootstrapper
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: VERSION bin/scala-bootstrapper lib/template/project/build/BirdNameProject.scala.erb lib/template/project/plugins/Plugins.scala.erb lib/template/src/main/scala/com/twitter/birdname/Main.scala.erb scala-bootstrapper.gemspec
- Loading branch information
Showing
17 changed files
with
219 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
kmaxwell | ||
robey | ||
review_group:Scala-Cafe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.10.0 | ||
0.10.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
lib/template/src/main/scala/com/twitter/birdname/BirdNameServiceImpl.scala.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
lib/template/src/main/scala/com/twitter/birdname/config/BirdNameServiceConfig.scala.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
package com.twitter.birdname | ||
package config | ||
|
||
import com.twitter.finagle.tracing.{NullTracer, Tracer} | ||
import com.twitter.logging.Logger | ||
import com.twitter.logging.config._ | ||
import com.twitter.ostrich.admin.{RuntimeEnvironment, ServiceTracker} | ||
import com.twitter.ostrich.admin.config._ | ||
import com.twitter.util.Config | ||
import thrift._ | ||
|
||
class BirdNameServiceConfig extends ServerConfig[BirdNameService.ThriftServer] { | ||
var thriftPort: Int = 9999 | ||
var tracerFactory: Tracer.Factory = NullTracer.factory | ||
|
||
def apply(runtime: RuntimeEnvironment) = new BirdNameServiceImpl(this) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
sh `dirname "$0"`/service.sh "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/sh | ||
|
||
export APP_NAME="birdname" | ||
export APP_HOME="/usr/local/$APP_NAME/current" | ||
|
||
export PIDFILE="/var/run/$APP_NAME/$APP_NAME.pid" | ||
export STDOUT_FILE="/var/log/$APP_NAME/stdout" | ||
export STDERR_FILE="/var/log/$APP_NAME/error" | ||
|
||
export MAIN_JAR="$APP_NAME-1.0-SNAPSHOT.jar" | ||
export ADMIN_PORT=9900 | ||
|
||
export HEAP_OPTS="-Xmx4096m -Xms4096m -XX:NewSize=768m" | ||
export GC_OPTS="-XX:+UseParallelOldGC -XX:+UseAdaptiveSizePolicy -XX:MaxGCPauseMillis=1000 -XX:GCTimeRatio=99" | ||
|
||
export STAGE=production | ||
export EXTRA_JAVA_OPTS="-Dstage=$STAGE" | ||
|
||
# you can also define the following functions to override behavior: | ||
# running - checks whether the process is running | ||
# start - executed after the process is verified to not be running and a start was requested | ||
# stop - executed after the process is verified to be running and a stop was requested | ||
# stopped - is passed the PID before ths top and checks if its still running |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
echo "Starting birdname in development mode..." | ||
java -server -Xmx1024m -Dstage=development -jar ./dist/birdname/birdname-@VERSION@.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/sh | ||
## this file encapsulates starting the server including the JVM options | ||
## and putting the pid into the pidfile. this is executed by service.sh | ||
## on the start action. | ||
## it is an expectation that this be run in your application home directory. | ||
|
||
SCRIPT_DIR=`dirname $0` | ||
source "$SCRIPT_DIR/config.sh" | ||
|
||
GC_LOGGING_OPTS="-verbosegc -Xloggc:/var/log/$APP_NAME/gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintHeapAtGC" | ||
JAVA_OPTS="-server -XX:+DisableExplicitGC -XX:+UseNUMA $GC_OPTS $GC_LOGGING_OPTS $HEAP_OPTS $EXTRA_JAVA_OPTS" | ||
|
||
if [ -z $APP_HOME ]; then | ||
APP_HOME=`pwd` | ||
fi | ||
|
||
if [ -z $PIDFILE ]; then | ||
PIDFILE="/var/run/$APP_NAME/$APP_NAME.pid" | ||
fi | ||
|
||
if [ ! -f "$APP_HOME/$MAIN_JAR" ]; then | ||
echo "jar not found at $APP_HOME/$MAIN_JAR" | ||
exit 1 | ||
fi | ||
|
||
if [ -z $JAVA_HOME ]; then | ||
JAVA_HOME="/usr/java/default" | ||
fi | ||
|
||
echo $$ > $PIDFILE | ||
exec ${JAVA_HOME}/bin/java ${JAVA_OPTS} -jar ${APP_HOME}/${MAIN_JAR} ${CMD_OPTS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#!/bin/sh | ||
## this file is the control script for your jvm service. | ||
## it is executed by monit with an argument of either start, stop or restart | ||
## it is not responsible for options specific to the jvm but does background, | ||
## disown, and redirect output. | ||
|
||
function start() { | ||
cd $APP_HOME | ||
$START_SCRIPT > $STDOUT_FILE 2> $STDERR_FILE & | ||
disown %1 | ||
|
||
sleep $INITIAL_SLEEP # give it time to compile config files and bind to ports | ||
} | ||
|
||
function running() { | ||
curl -m 5 -s "http://localhost:$ADMIN_PORT/ping.txt" > /dev/null 2> /dev/null | ||
} | ||
|
||
function stop() { | ||
kill -TERM $(cat $PIDFILE) | ||
} | ||
|
||
function stopped() { | ||
! kill -0 $1 > /dev/null 2> /dev/null | ||
} | ||
|
||
SCRIPT_DIR=`dirname $0` | ||
source "$SCRIPT_DIR/config.sh" | ||
START_SCRIPT="sh $SCRIPT_DIR/server.sh" | ||
|
||
if [ -z $INITIAL_SLEEP ]; then | ||
INITIAL_SLEEP=3 | ||
fi | ||
|
||
if [ -z $MAX_START_TRIES ]; then | ||
MAX_START_TRIES=5 | ||
fi | ||
|
||
case "$1" in | ||
start) | ||
printf "Starting %s... " "$APP_NAME" | ||
|
||
if running; then | ||
echo "already running." | ||
exit 0 | ||
fi | ||
|
||
start | ||
|
||
tries=0 | ||
while ! running; do | ||
tries=$((tries + 1)) | ||
if [ $tries -ge $MAX_START_TRIES ]; then | ||
echo "ERROR: failed to start" | ||
exit 1 | ||
fi | ||
sleep 1 | ||
done | ||
echo "done." | ||
;; | ||
|
||
stop) | ||
printf "Stopping %s... " "$APP_NAME" | ||
|
||
if [ ! -f $PIDFILE ]; then | ||
GUESSED_PID=`pgrep -u $USER java` | ||
if [ -z $GUESSED_PID ]; then | ||
echo "ERROR: no pid file and no java process found" | ||
else | ||
echo "ERROR: no pid file, but found java process: $GUESSED_PID" | ||
fi | ||
exit 1 | ||
fi | ||
|
||
SNAPSHOT_PID=$(cat $PIDFILE) | ||
|
||
if $(stopped $SNAPSHOT_PID); then | ||
echo "already stopped." | ||
exit 0 | ||
fi | ||
|
||
stop | ||
|
||
tries=0 | ||
while ! $(stopped $SNAPSHOT_PID); do | ||
tries=$((tries + 1)) | ||
if [ $tries -ge 5 ]; then | ||
echo "ERROR: failed to stop" | ||
exit 1 | ||
fi | ||
sleep 1 | ||
done | ||
echo "done." | ||
;; | ||
|
||
status) | ||
if running; then | ||
echo "$APP_NAME is running." | ||
else | ||
echo "$APP_NAME is NOT running." | ||
fi | ||
;; | ||
|
||
restart) | ||
$0 stop | ||
sleep 2 | ||
$0 start | ||
;; | ||
|
||
*) | ||
echo "Usage: /etc/init.d/$APP_NAME {start|stop|restart|status}" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
exit 0 |
Oops, something went wrong.