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

fix sysv init scripts #502

Merged
merged 1 commit into from
Nov 22, 2020
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
2 changes: 1 addition & 1 deletion spec/defines/daemon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
'owner' => 'root',
'group' => 'root'
).with_content(
%r{daemon --user=smurf_user \\\n --pidfile="\$PID_FILE" \\\n "\$DAEMON" '' >> "\$LOG_FILE" 2>&1 &}
%r{daemon --user=smurf_user \\\n --pidfile="\$PID_FILE" \\\n "'\$DAEMON' '' >> '\$LOG_FILE' 2>&1 &"}
)
}

Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/files/prometheus1.sysv
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ start() {
[ -f $PID_FILE ] && rm $PID_FILE
daemon --user=prometheus \
--pidfile="$PID_FILE" \
"$DAEMON" -log.format logger:stdout -config.file=/etc/prometheus/prometheus.yaml \
"'$DAEMON' -log.format logger:stdout -config.file=/etc/prometheus/prometheus.yaml \
-web.console.templates=/usr/local/share/prometheus/consoles \
-web.console.libraries=/usr/local/share/prometheus/console_libraries \
-storage.local.path=/var/lib/prometheus \
-storage.local.retention=360h \
>> "$LOG_FILE" &
>> '$LOG_FILE' 2>&1 &"
Copy link
Member

Choose a reason for hiding this comment

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

can you explain what this actually fixes? support paths with whitespace?

Copy link

Choose a reason for hiding this comment

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

Hi, without the additional double quotes parent startup processes remain after startup and logfiles are touched as root.
e.g.

`
/bin/bash /etc/init.d/prometheus restart (root)
\_ runuser -s /bin/bash prometheus -c ulimit -S -c 0 >/dev/null ... (root)

\_ bash -c ulimit -S -c 0 >/dev/null 2>&1 ; /usr/local/bin/prometheus --config.file... (prometheus)

\_ /usr/local/bin/prometheus --config.file=/etc/prometheus/prometheus.yaml --web.console.... (prometheus)
`

compared to

493 56754 6.0 0.0 774908 53652 ? Sl 09:18 0:00 /usr/local/bin/prometheus --config.file=/etc/prometheus/prometheus.yaml --web.console.templates=/usr/local/share/prometheus/consoles --web.console.libraries=/usr/local/share/prometheus/console_libraries --st

retcode=$?
mkpidfile
touch /var/lock/subsys/prometheus
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/files/prometheus2.sysv
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ start() {
[ -f $PID_FILE ] && rm $PID_FILE
daemon --user=prometheus \
--pidfile="$PID_FILE" \
"$DAEMON" --config.file=/etc/prometheus/prometheus.yaml \
"'$DAEMON' --config.file=/etc/prometheus/prometheus.yaml \
--web.console.templates=/usr/local/share/prometheus/consoles \
--web.console.libraries=/usr/local/share/prometheus/console_libraries \
--storage.tsdb.path=/var/lib/prometheus \
--storage.tsdb.retention=360h \
>> "$LOG_FILE" &
>> '$LOG_FILE' 2>&1 &"
retcode=$?
mkpidfile
touch /var/lock/subsys/prometheus
Expand Down
2 changes: 1 addition & 1 deletion templates/daemon.sysv.erb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ start() {
daemon --user=<%= @user %> \
--pidfile="$PID_FILE" \
<%- require 'shellwords' -%>
"$DAEMON" <%= Shellwords.escape(@options) %> >> "$LOG_FILE" 2>&1 &
"'$DAEMON' <%= Shellwords.escape(@options) %> >> '$LOG_FILE' 2>&1 &"
retcode=$?
sleep 1
mkpidfile
Expand Down
4 changes: 2 additions & 2 deletions templates/prometheus.sysv.erb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ start() {
[ -f $PID_FILE ] && rm $PID_FILE
daemon --user=<%= scope.lookupvar('prometheus::server::user') %> \
--pidfile="$PID_FILE" \
"$DAEMON" <%= @daemon_flags.join(" \\\n ") %> \
>> "$LOG_FILE" &
"'$DAEMON' <%= @daemon_flags.join(" \\\n ") %> \
>> '$LOG_FILE' 2>&1 &"
retcode=$?
mkpidfile
touch /var/lock/subsys/prometheus
Expand Down