diff --git a/bench/bench.sh b/bench/bench.sh index ea3449a..4112376 100644 --- a/bench/bench.sh +++ b/bench/bench.sh @@ -2,7 +2,7 @@ echo "----------------------------" echo "Benchmark on rpxy" -ab -c 32 -n 10000 http://127.0.0.1:8080/ +ab -c 32 -n 10000 http://127.0.0.1:8080/ # TODO: localhost = 127.0.0.1を解決できるように決めておかんとだめそう echo "----------------------------" echo "Benchmark on nginx" diff --git a/docker-bin/entrypoint.sh b/docker-bin/entrypoint.sh new file mode 100644 index 0000000..e0ceed5 --- /dev/null +++ b/docker-bin/entrypoint.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +LOG_FILE=/var/log/rpxy/rpxy.log + +/run.sh 2>&1 | tee $LOG_FILE diff --git a/docker-bin/run.sh b/docker-bin/run.sh new file mode 100644 index 0000000..e89d790 --- /dev/null +++ b/docker-bin/run.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +LOG_FILE=/var/log/rpxy/rpxy.log +CONFIG_FILE=/etc/rpxy.toml +LOG_SIZE=10M +LOG_NUM=10 + +# logrotate +if [ $LOGROTATE_NUM ]; then + LOG_NUM=${LOGROTATE_NUM} +fi +if [ $LOGROTATE_SIZE ]; then + LOG_SIZE=${LOGROTATE_SIZE} +fi + +cat > /etc/logrotate.conf << EOF +# see "man logrotate" for details +# rotate log files weekly +weekly +# use the adm group by default, since this is the owning group +# of /var/log/syslog. +su root adm +# keep 4 weeks worth of backlogs +rotate 4 +# create new (empty) log files after rotating old ones +create +# use date as a suffix of the rotated file +#dateext +# uncomment this if you want your log files compressed +#compress +# packages drop log rotation information into this directory +include /etc/logrotate.d +# system-specific logs may be also be configured here. +EOF + +cat > /etc/logrotate.d/rpxy << EOF +${LOG_FILE} { + dateext + daily + missingok + rotate ${LOG_NUM} + notifempty + compress + delaycompress + dateformat -%Y-%m-%d-%s + size ${LOG_SIZE} + copytruncate +} +EOF + +cp -p /etc/cron.daily/logrotate /etc/cron.hourly/ +service cron start + +echo "Start rpxy" + +RUST_LOG=info /opt/rpxy/sbin/rpxy --config ${CONFIG_FILE}