Skip to content

added systemd reload commands#694

Merged
franku merged 1 commit intobareos:masterfrom
benibr:feature/systemd_reload
Jan 19, 2021
Merged

added systemd reload commands#694
franku merged 1 commit intobareos:masterfrom
benibr:feature/systemd_reload

Conversation

@benibr
Copy link
Contributor

@benibr benibr commented Dec 18, 2020

This PR adds reload commands for the Bareos director. It first tests the configuration and then sends a SIGHUP to the main process.
If the config tests fails a log message will be reported, but the SIGHUP is fired anyway.

@benibr
Copy link
Contributor Author

benibr commented Dec 18, 2020

A failed reload would look like this in the logs which is bad, as it suggest a successfull reload:

● bareos-director.service - Bareos Director Daemon service
   Loaded: loaded (/lib/systemd/system/bareos-director.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-12-18 17:31:22 CET; 1h 57min ago
     Docs: man:bareos-dir(8)
  Process: 9643 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
  Process: 9641 ExecReload=/usr/sbin/bareos-dir -t -f (code=exited, status=1/FAILURE)
 Main PID: 21668 (bareos-dir)
    Tasks: 3 (limit: 4703)
   CGroup: /system.slice/bareos-director.service
           └─21668 /usr/sbin/bareos-dir

Dec 18 19:23:38 bareos-director01 systemd[1]: Reloading Bareos Director Daemon service.
Dec 18 19:23:38 bareos-director01 bareos-dir[9641]: bareos-dir: ERROR TERMINATION at lib/parse_conf_state_machine.cc:249
Dec 18 19:23:38 bareos-director01 bareos-dir[9641]: Config error: expected resource identifier, got: invalidconfig
Dec 18 19:23:38 bareos-director01 bareos-dir[9641]:             : line 2, col 15 of file /etc/bareos/bareos-dir.d/director/bareos-dir.conf
Dec 18 19:23:38 bareos-director01 bareos-dir[9641]: invalid config
Dec 18 19:23:38 bareos-director01 systemd[1]: Reloaded Bareos Director Daemon service.

@benibr
Copy link
Contributor Author

benibr commented Dec 18, 2020

Another option would be to use a shell:

/bin/sh -c /usr/sbin/bareos-dir -t -f && kill -HUP $MAINPID

then the failed reload looks like:

● bareos-director.service - Bareos Director Daemon service
   Loaded: loaded (/lib/systemd/system/bareos-director.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-12-18 17:31:22 CET; 2h 15min ago
     Docs: man:bareos-dir(8)
  Process: 27128 ExecReload=/bin/sh -c /usr/sbin/bareos-dir -t -f && kill -HUP $MAINPID (code=exited, status=1/FAILURE)
 Main PID: 21668 (bareos-dir)
    Tasks: 4 (limit: 4703)
   CGroup: /system.slice/bareos-director.service
           └─21668 /usr/sbin/bareos-dir

Dec 18 19:46:11 bareos-director01 systemd[1]: Reloaded Bareos Director Daemon service.
Dec 18 19:46:33 bareos-director01 systemd[1]: Reloading Bareos Director Daemon service.
Dec 18 19:46:33 bareos-director01 sh[27128]: bareos-dir: ERROR TERMINATION at lib/parse_conf_state_machine.cc:249
Dec 18 19:46:33 bareos-director01 sh[27128]: Config error: expected resource identifier, got: invalidconf
Dec 18 19:46:33 bareos-director01 sh[27128]:             : line 2, col 13 of file /etc/bareos/bareos-dir.d/director/bareos-dir.conf
Dec 18 19:46:33 bareos-director01 sh[27128]: invalid conf
Dec 18 19:46:33 bareos-director01 systemd[1]: Reloaded Bareos Director Daemon service.

@benibr
Copy link
Contributor Author

benibr commented Dec 18, 2020

feedback welcome :-)

Copy link
Contributor

@franku franku left a comment

Choose a reason for hiding this comment

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

Approved during Teammeeting

@franku
Copy link
Contributor

franku commented Jan 15, 2021

Thanks for your contribution. However, please squash your two commits into one and give it a reasonable subject text:
dird: add systemd reload command

@franku franku self-assigned this Jan 15, 2021
@benibr benibr force-pushed the feature/systemd_reload branch from 6fb0f9b to 6f6c87e Compare January 15, 2021 14:19
@benibr
Copy link
Contributor Author

benibr commented Jan 15, 2021

Thanks for your contribution. However, please squash your two commits into one and give it a reasonable subject text:
dird: add systemd reload command

done

@franku franku merged commit 46f3b16 into bareos:master Jan 19, 2021
@franku
Copy link
Contributor

franku commented Jan 20, 2021

Would you like to have your name added to the AUTHORS list? Just saw it's not there, yet.

@benibr
Copy link
Contributor Author

benibr commented Jan 20, 2021

I'd love to. Do you want a PR for that?

@franku
Copy link
Contributor

franku commented Jan 20, 2021

Awesome! I wonder if you also could add an item to CHANGELOG.md, too?
Sorry, I forgot that in the first run.

Thanks!

@benibr benibr mentioned this pull request Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants