Skip to content

Commit

Permalink
Add systemd environment file for deb/rpm packages (open-telemetry#2822)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchengsfx authored Mar 26, 2021
1 parent 02d0f2f commit d9b2c4b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/buildscripts/packaging/fpm/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ SERVICE_NAME="otel-collector"
PROCESS_NAME="otelcol"

SERVICE_PATH="$FPM_DIR/$SERVICE_NAME.service"
ENVFILE_PATH="$FPM_DIR/$SERVICE_NAME.conf"
PREINSTALL_PATH="$FPM_DIR/preinstall.sh"
POSTINSTALL_PATH="$FPM_DIR/postinstall.sh"
PREUNINSTALL_PATH="$FPM_DIR/preuninstall.sh"
Expand Down
2 changes: 2 additions & 0 deletions internal/buildscripts/packaging/fpm/deb/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ fpm -s dir -t deb -n $PKG_NAME -v ${VERSION#v} -f -p "$OUTPUT_DIR" \
--license "$PKG_LICENSE" \
--url "$PKG_URL" \
--architecture "$ARCH" \
--config-files /etc/otel-collector/otel-collector.conf \
--config-files /etc/otel-collector/config.yaml \
--deb-dist "stable" \
--deb-user "$PKG_USER" \
Expand All @@ -49,4 +50,5 @@ fpm -s dir -t deb -n $PKG_NAME -v ${VERSION#v} -f -p "$OUTPUT_DIR" \
--pre-uninstall "$PREUNINSTALL_PATH" \
$OTELCOL_PATH=/usr/bin/$PROCESS_NAME \
$SERVICE_PATH=/lib/systemd/system/$SERVICE_NAME.service \
$ENVFILE_PATH=/etc/otel-collector/otel-collector.conf \
$CONFIG_PATH=/etc/otel-collector/config.yaml
5 changes: 5 additions & 0 deletions internal/buildscripts/packaging/fpm/otel-collector.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Systemd environment file for the otel-collector service

# Command-line options for the otel-collector service.
# Run `/usr/bin/otelcol --help` to see all available options.
OTELCOL_OPTIONS="--config=/etc/otel-collector/config.yaml"
3 changes: 2 additions & 1 deletion internal/buildscripts/packaging/fpm/otel-collector.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Description=OpenTelemety Collector
After=network.target

[Service]
ExecStart=/usr/bin/otelcol --config /etc/otel-collector/config.yaml
EnvironmentFile=/etc/otel-collector/otel-collector.conf
ExecStart=/usr/bin/otelcol $OTELCOL_OPTIONS
KillMode=mixed
Restart=on-failure
Type=simple
Expand Down
2 changes: 2 additions & 0 deletions internal/buildscripts/packaging/fpm/rpm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ fpm -s dir -t rpm -n $PKG_NAME -v ${VERSION#v} -f -p "$OUTPUT_DIR" \
--license "$PKG_LICENSE" \
--url "$PKG_URL" \
--architecture "$ARCH" \
--config-files /etc/otel-collector/otel-collector.conf \
--config-files /etc/otel-collector/config.yaml \
--rpm-summary "$PKG_DESCRIPTION" \
--rpm-user "$PKG_USER" \
Expand All @@ -49,4 +50,5 @@ fpm -s dir -t rpm -n $PKG_NAME -v ${VERSION#v} -f -p "$OUTPUT_DIR" \
--pre-uninstall "$PREUNINSTALL_PATH" \
$OTELCOL_PATH=/usr/bin/$PROCESS_NAME \
$SERVICE_PATH=/lib/systemd/system/$SERVICE_NAME.service \
$ENVFILE_PATH=/etc/otel-collector/otel-collector.conf \
$CONFIG_PATH=/etc/otel-collector/config.yaml

0 comments on commit d9b2c4b

Please sign in to comment.