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

Improve nipapd PID file handling #1349

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ jobs:
# create local user for unittest and restart
sudo nipap-passwd add -u unittest -p gottatest -f /etc/nipap/local_auth.db -n unittest
sudo systemctl restart nipapd.service
sudo systemctl status nipapd.service
# add some data to the database that we can verify later
nosetests3 tests/upgrade-before.py
# bump version so that we know we are upgrading beyond what is installed
Expand Down Expand Up @@ -144,6 +145,7 @@ jobs:
sudo nipap/nipap-passwd add -u readonly -p gottatest -f /etc/nipap/local_auth.db --readonly -n "Read-only user for running unit tests"
sudo sed -e "s/^db_host *=.*/db_host = localhost/" -e "s/{{SYSLOG}}/true/" -e "s/^debug.\+/debug = true/" -e "s/^user/#user/" -i /etc/nipap/nipap.conf
sudo systemctl restart nipapd.service
sudo systemctl status nipapd.service

- name: "Verify pre-upgrade data"
if: ${{ matrix.upgrade == true }}
Expand All @@ -163,6 +165,7 @@ jobs:
- name: "Accident analysis"
if: failure()
run: |
sudo systemctl status nipapd.service
sudo cat /etc/nipap/nipap.conf
sudo cat /var/log/syslog
sudo cat /tmp/nipap.log || true
3 changes: 2 additions & 1 deletion nipap/debian/nipapd.init
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CONFIGFILE=/etc/nipap/nipap.conf
NAME=NIPAPd
PIDFILE=/var/run/nipap/nipapd.pid
PIDDIR=`dirname $PIDFILE`
USER=nipap

. /lib/lsb/init-functions

Expand Down Expand Up @@ -74,7 +75,7 @@ case "$1" in
log_daemon_msg "Stopping NIPAPd XML-RPC server" "nipapd"
RUNNING=$(running)
if [ -n "$RUNNING" ]; then
if start-stop-daemon --stop --pidfile $PIDFILE --retry 30; then
if start-stop-daemon --stop --pidfile $PIDFILE --user $USER --retry 30; then
log_end_msg 0
else
log_end_msg 1
Expand Down
1 change: 1 addition & 0 deletions nipap/nipapd
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ if __name__ == '__main__':
# need a+ to be able to read PID from file
try:
lf = open(cfg.get('nipapd', 'pid_file'), 'a+')
os.chmod(cfg.get('nipapd', 'pid_file'), 0o644)
lf.seek(0)
except IOError as exc:
logger.error("Unable to open PID file '" + str(exc.filename) + "': " + str(exc.strerror))
Expand Down
Loading