Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install logrotate configuration #4033

Merged
merged 4 commits into from
Sep 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ With this release InfluxDB is moving to Go 1.5.
- [#3986](https://github.com/influxdb/influxdb/pull/3986): Support sorting by time desc
- [#3930](https://github.com/influxdb/influxdb/pull/3930): Wire up TOP aggregate function - fixes [#1821](https://github.com/influxdb/influxdb/issues/1821)
- [#3996](https://github.com/influxdb/influxdb/pull/3996): Add statistics to httpd package
- [#4003](https://github.com/influxdb/influxdb/pull/4033): Add logrotate configuration.

### Bugfixes
- [#3804](https://github.com/influxdb/influxdb/pull/3804): init.d script fixes, fixes issue 3803.
Expand Down
29 changes: 21 additions & 8 deletions package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ INSTALL_ROOT_DIR=/opt/influxdb
INFLUXDB_LOG_DIR=/var/log/influxdb
INFLUXDB_DATA_DIR=/var/opt/influxdb
CONFIG_ROOT_DIR=/etc/opt/influxdb
LOGROTATE_DIR=/etc/logrotate.d

SAMPLE_CONFIGURATION=etc/config.sample.toml
INITD_SCRIPT=scripts/init.sh
LOGROTATE=scripts/logrotate

TMP_WORK_DIR=`mktemp -d`
POST_INSTALL_PATH=`mktemp`
Expand Down Expand Up @@ -179,36 +181,41 @@ make_dir_tree() {
echo "Failed to create configuration directory -- aborting."
cleanup_exit 1
fi
mkdir -p $work_dir/$LOGROTATE_DIR
if [ $? -ne 0 ]; then
echo "Failed to create logrotate directory -- aborting."
cleanup_exit 1
fi
}

# do_build builds the code. The version and commit must be passed in.
do_build() {
for b in ${BINS[*]}; do
rm -f $GOPATH_INSTALL/bin/$b
done

if [ -n "$WORKING_DIR" ]; then
STASH=`git stash create -a`
if [ $? -ne 0 ]; then
echo "WARNING: failed to stash uncommited local changes"
fi
git reset --hard
fi

go get -u -f -d ./...
if [ $? -ne 0 ]; then
echo "WARNING: failed to 'go get' packages."
fi

git checkout $TARGET_BRANCH # go get switches to master, so ensure we're back.

if [ -n "$WORKING_DIR" ]; then
git stash apply $STASH
if [ $? -ne 0 ]; then #and apply previous uncommited local changes
echo "WARNING: failed to restore uncommited local changes"
fi
fi

version=$1
commit=`git rev-parse HEAD`
branch=`current_branch`
Expand Down Expand Up @@ -266,7 +273,7 @@ EOF
while :
do
case $1 in
-h | --help)
-h | --help)
usage 0
;;
-p | --packages-only)
Expand All @@ -292,7 +299,7 @@ do
PACKAGES_ONLY="PACKAGES_ONLY"
WORKING_DIR="WORKING_DIR"
shift
;;
;;
-*)
echo "Unknown option $1"
usage 1
Expand All @@ -314,7 +321,7 @@ done
if [ -z "$DEB_WANTED$RPM_WANTED$TAR_WANTED" ]; then
TAR_WANTED="gz"
DEB_WANTED="deb"
RPM_WANTED="rpm"
RPM_WANTED="rpm"
fi

if [ -z "$VERSION" ]; then
Expand Down Expand Up @@ -375,6 +382,12 @@ if [ $? -ne 0 ]; then
cleanup_exit 1
fi

cp $LOGROTATE $TMP_WORK_DIR/$LOGROTATE_DIR/influxdb.conf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logrotate config should be at /etc/logrotate.d/influxdb, which I think matches this line except I'd leave off the .conf.

if [ $? -ne 0 ]; then
echo "Failed to copy logrotate configuration to packaging directory -- aborting."
cleanup_exit 1
fi

generate_postinstall_script $VERSION

###########################################################################
Expand Down Expand Up @@ -403,7 +416,7 @@ else
debian_package=influxdb_${VERSION}_amd64.deb
fi

COMMON_FPM_ARGS="--log error -C $TMP_WORK_DIR --vendor $VENDOR --url $URL --license $LICENSE --maintainer $MAINTAINER --after-install $POST_INSTALL_PATH --name influxdb --version $VERSION --config-files $CONFIG_ROOT_DIR ."
COMMON_FPM_ARGS="--log error -C $TMP_WORK_DIR --vendor $VENDOR --url $URL --license $LICENSE --maintainer $MAINTAINER --after-install $POST_INSTALL_PATH --name influxdb --version $VERSION --config-files $CONFIG_ROOT_DIR --config-files $LOGROTATE_DIR."

if [ -n "$DEB_WANTED" ]; then
$FPM -s dir -t deb $deb_args --description "$DESCRIPTION" $COMMON_FPM_ARGS
Expand Down
8 changes: 8 additions & 0 deletions scripts/logrotate
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/var/log/influxdb/influxd.log {
daily
rotate 7
missingok
dateext
copytruncate
compress
}