-
Notifications
You must be signed in to change notification settings - Fork 23
Improve and actualize orchestrator-agent , extract many LVM commands into configuration file #20
base: master
Are you sure you want to change the base?
Changes from 15 commits
32ec11b
ad5b6a8
0d08d34
56e4362
caa8db6
de935cc
ac7cf93
0d74d97
3055395
5d1b823
fb2e214
16f920c
0772999
b2d10ed
46468cd
9450b7d
66cb2a2
5c0dddb
8febb27
17700a7
4056d58
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,11 @@ DESC="orchestrator-agent: MySQL management agent" | |
| PIDFILE=/var/run/$NAME.pid | ||
| SCRIPTNAME=/etc/init.d/$NAME | ||
|
|
||
| # This files can be used to inject pre-service execution | ||
| # scripts, such as exporting variables or whatever. It's yours! | ||
| [ -f /etc/default/orchestrator-agent ] && . /etc/default/orchestrator-agent | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very good. If we're down this rabbit hole, let's also add
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /etc/profile.d/orchestrator-agent |
||
| [ -f /etc/orchestrator-agent_profile ] && . /etc/orchestrator-agent_profile | ||
|
|
||
| case "$1" in | ||
| start) | ||
| printf "%-50s" "Starting $NAME..." | ||
|
|
@@ -60,21 +65,39 @@ case "$1" in | |
| PID=$(cat $PIDFILE) | ||
| cd $DAEMON_PATH | ||
| if [ -f $PIDFILE ]; then | ||
| kill -HUP $PID | ||
| printf "%s\n" "Ok" | ||
| kill -TERM $PID | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| rm -f $PIDFILE | ||
| # Wait for orchestrator to stop otherwise restart may fail. | ||
|
||
| # (The newly restarted process may be unable to bind to the | ||
| # currently bound socket.) | ||
| while ps -p $PID >/dev/null 2>&1; do | ||
| printf "." | ||
| sleep 1 | ||
| done | ||
| printf "\n" | ||
| printf "Ok\n" | ||
| else | ||
| printf "%s\n" "pidfile not found" | ||
| exit 1 | ||
| fi | ||
| ;; | ||
|
|
||
| restart) | ||
| $0 stop | ||
| $0 start | ||
| ;; | ||
|
|
||
| reload) | ||
| printf "%-50s" "Reloading $NAME" | ||
| PID=$(cat $PIDFILE) | ||
| cd $DAEMON_PATH | ||
| if [ -f $PIDFILE ]; then | ||
| kill -HUP $PID | ||
| printf "%s\n" "Ok" | ||
| else | ||
| printf "%s\n" "pidfile not found" | ||
| exit 1 | ||
| fi | ||
| ;; | ||
| *) | ||
| echo "Usage: $0 {status|start|stop|restart}" | ||
| echo "Usage: $0 {status|start|stop|restart|reload}" | ||
| exit 1 | ||
| esac | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,11 +33,22 @@ var AppVersion string | |
|
|
||
| func acceptSignal() { | ||
| c := make(chan os.Signal, 1) | ||
| signal.Notify(c, os.Interrupt, os.Kill, syscall.SIGHUP) | ||
|
|
||
| // Block until a signal is received. | ||
| sig := <-c | ||
| log.Fatalf("Got signal: %+v", sig) | ||
| signal.Notify(c, syscall.SIGHUP, syscall.SIGKILL, syscall.SIGTERM, syscall.SIGTERM) | ||
| go func() { | ||
|
||
| for sig := range c { | ||
| switch sig { | ||
| case syscall.SIGHUP: | ||
| log.Infof("Received SIGHUP. Reloading configuration") | ||
| config.Reload() | ||
| case syscall.SIGTERM, syscall.SIGKILL, syscall.SIGINT: | ||
| log.Infof("Received %s. Shutting down orchestrator-agent", sig.String()) | ||
| // probably should poke other go routines to stop cleanly here ... | ||
|
||
| os.Exit(0) | ||
| } | ||
| } | ||
| }() | ||
| } | ||
|
|
||
| // main is the application's entry point. It will either spawn a CLI or HTTP itnerfaces. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer using conventional
shellnaming, e.g.${SNAPSHOT_MOUNT_POINT}. This applies to all of the rest of the variables.