{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/7415","repository_url":"https://api.github.com/repos/spring-projects/spring-boot","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/7415/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/7415/comments","events_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/7415/events","html_url":"https://github.com/spring-projects/spring-boot/issues/7415","id":190276220,"number":7415,"title":"Enhancement request: Source . /lib/lsb/init-functions in the init script","user":{"login":"oneiros-de","id":906250,"avatar_url":"https://avatars.githubusercontent.com/u/906250?v=3","gravatar_id":"","url":"https://api.github.com/users/oneiros-de","html_url":"https://github.com/oneiros-de","followers_url":"https://api.github.com/users/oneiros-de/followers","following_url":"https://api.github.com/users/oneiros-de/following{/other_user}","gists_url":"https://api.github.com/users/oneiros-de/gists{/gist_id}","starred_url":"https://api.github.com/users/oneiros-de/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oneiros-de/subscriptions","organizations_url":"https://api.github.com/users/oneiros-de/orgs","repos_url":"https://api.github.com/users/oneiros-de/repos","events_url":"https://api.github.com/users/oneiros-de/events{/privacy}","received_events_url":"https://api.github.com/users/oneiros-de/received_events","type":"User","site_admin":false},"labels":[{"id":293438798,"url":"https://api.github.com/repos/spring-projects/spring-boot/labels/waiting-for-triage","name":"waiting-for-triage","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-18T09:45:48Z","updated_at":"2016-11-18T10:12:15Z","closed_at":null,"body":"We are using services created with Spring Boot on Debian 8, i.e. with systemd. We create unit files and deploy them along with the jar symlinked to `/etc/init.d/`, so systemd uses the unit files after a `systemctl enable`. \r\n\r\nBut the init script is still there and can be used. But since it doesn't redirect to service or systemctl it does not know if the service was started by systemd and will start/stop a _second_ instance of the service if called with `start`/`stop`.\r\n\r\nThe solution for this employed by other init scripts seems to be source  `/lib/lsb/init-functions` early in the script as that will somehow redirect the script to systemd (I'm not an expert for systemd on Debian).\r\n\r\nI could find no simple way to patch that into the init script during our build process and it seems to be a feature useful to others."},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/comments/261495758","html_url":"https://github.com/spring-projects/spring-boot/issues/7415#issuecomment-261495758","issue_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/7415","id":261495758,"user":{"login":"oneiros-de","id":906250,"avatar_url":"https://avatars.githubusercontent.com/u/906250?v=3","gravatar_id":"","url":"https://api.github.com/users/oneiros-de","html_url":"https://github.com/oneiros-de","followers_url":"https://api.github.com/users/oneiros-de/followers","following_url":"https://api.github.com/users/oneiros-de/following{/other_user}","gists_url":"https://api.github.com/users/oneiros-de/gists{/gist_id}","starred_url":"https://api.github.com/users/oneiros-de/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oneiros-de/subscriptions","organizations_url":"https://api.github.com/users/oneiros-de/orgs","repos_url":"https://api.github.com/users/oneiros-de/repos","events_url":"https://api.github.com/users/oneiros-de/events{/privacy}","received_events_url":"https://api.github.com/users/oneiros-de/received_events","type":"User","site_admin":false},"created_at":"2016-11-18T10:12:15Z","updated_at":"2016-11-18T10:12:15Z","body":"> Just sourcing `/lib/lsb/init-functions` doesn't really have any effect as all it does it to make a number of functions available to the rest of the script. If the rest of the script doesn't use those functions, as is the case with the launch script, then it won't do anything.\r\n\r\nIt will also source `/lib/lsb/init-functions.d/40-systemd` which has this code block:\r\n```\r\nsystemctl_redirect () {\r\n    local s\r\n    local rc\r\n    local prog=${1##*/}\r\n    local command=$2\r\n\r\n    case \"$command\" in\r\n        start)\r\n            s=\"Starting $prog (via systemctl)\"\r\n            ;;\r\n        stop)\r\n            s=\"Stopping $prog (via systemctl)\"\r\n            ;;\r\n        reload|force-reload)\r\n            s=\"Reloading $prog configuration (via systemctl)\"\r\n            ;;\r\n        restart)\r\n            s=\"Restarting $prog (via systemctl)\"\r\n            ;;\r\n    esac\r\n\r\n    service=\"${prog%.sh}.service\"\r\n\r\n    # Don't try to run masked services. Don't check for errors, if\r\n    # this errors, we'll just call systemctl and possibly explode\r\n    # there.\r\n    state=$(systemctl -p LoadState show $service 2>/dev/null)\r\n    [ \"$state\" = \"LoadState=masked\" ] && return 0\r\n\r\n    [ \"$command\" = status ] || log_daemon_msg \"$s\" \"$service\"\r\n    /bin/systemctl $command \"$service\"\r\n    rc=$?\r\n    [ \"$command\" = status ] || log_end_msg $rc\r\n\r\n    return $rc\r\n}\r\n\r\nif [ \"$_use_systemctl\" = \"1\" ]; then\r\n    # Some init scripts use \"set -e\" and \"set -u\", we don't want that\r\n    # here\r\n    set +e\r\n    set +u\r\n\r\n    if  [ \"x$1\" = xstart -o \\\r\n        \"x$1\" = xstop -o \\\r\n        \"x$1\" = xrestart -o \\\r\n        \"x$1\" = xreload -o \\\r\n        \"x$1\" = xforce-reload -o \\\r\n        \"x$1\" = xstatus ] ; then\r\n\r\n        systemctl_redirect $0 $1\r\n        exit $?\r\n    fi\r\nfi\r\n\r\n```\r\nSo it *has* an effect as it will call ` systemctl_redirect`."}}
{"actor":{"display_login":"oneiros-de"}}