-
Notifications
You must be signed in to change notification settings - Fork 443
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
Wip/rpm server archetype #176
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e4c01ac
Replacing the _appUser_ and _appGroup_ with _daemonUser_ and
muuki88 5f615bd
Follow up changes (re check them)
muuki88 13fe73d
Fix #149 First draft of rpm systemV init script
muuki88 75a4a70
Adding uncommited debian start template
muuki88 04010ea
Adding an additional test. Need to generate mainClass for bin generation
muuki88 13097af
Removing crappy debugging stuff
muuki88 b34a38d
Adding checks for start script
muuki88 d6f88be
Adding daemon_user to nohup command.
muuki88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
133 changes: 133 additions & 0 deletions
133
src/main/resources/com/typesafe/sbt/packager/archetypes/systemv/start-rpm-template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
#!/bin/sh | ||
# | ||
# ${{app_name}} <${{app_name}}> | ||
# | ||
# chkconfig: - 20 80 | ||
# description: ${{descr}} | ||
# | ||
|
||
### BEGIN INIT INFO | ||
# Provides: ${{app_name}} | ||
# Required-Start: | ||
# Required-Stop: | ||
# Should-Start: | ||
# Should-Stop: | ||
# Default-Start: 2 3 4 5 | ||
# Default-Stop: 0 1 6 | ||
# Short-Description: ${{descr}} | ||
# Description: ${{descr}} | ||
### END INIT INFO | ||
|
||
### ----------------- | ||
# This script was created using following sources | ||
# | ||
# http://stackoverflow.com/questions/8124345/call-to-daemon-in-a-etc-init-d-script-is-blocking-not-running-in-background | ||
# https://fedoraproject.org/wiki/Packaging:SysVInitScript#Initscript_template | ||
### ----------------- | ||
|
||
# Source function library. | ||
. /etc/rc.d/init.d/functions | ||
|
||
prog="${{app_name}}" | ||
|
||
# FIXME The pid file should be handled by the executed script | ||
# The pid can be filled in in this script | ||
PIDFILE=/var/run/${{app_name}}/running.pid | ||
|
||
if [ -z "$DAEMON_USER" ]; then | ||
DAEMON_USER=${{daemon_user}} | ||
fi | ||
|
||
|
||
# smb could define some additional options in $RUN_OPTS | ||
RUN_CMD="${{chdir}}/bin/${{app_name}}" | ||
|
||
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog | ||
|
||
lockfile=/var/lock/subsys/$prog | ||
|
||
start() { | ||
[ -x $RUN_CMD ] || exit 5 | ||
echo -n $"Starting $prog: " | ||
cd ${{chdir}} | ||
|
||
# FIXME figure out how to use daemon correctly | ||
nohup runuser $DAEMON_USER ${RUN_CMD} >/dev/null 2>&1 & | ||
|
||
# The way to go, but doesn't work properly | ||
# If the app creates the pid file this gets messy | ||
# daemon --user $DAEMON_USER --pidfile $PIDFILE $RUN_CMD & | ||
|
||
|
||
retval=$? # last error code | ||
PID=$! # pid of last backgrounded process | ||
[ $retval -eq 0 ] && touch ${lockfile} && success || failure | ||
|
||
# Insert pid into pid file for CentOS killproc function | ||
echo | ||
echo $PID > ${PIDFILE} | ||
return $retval | ||
} | ||
|
||
stop() { | ||
echo -n $"Stopping $prog: " | ||
killproc -p $PIDFILE $prog | ||
retval=$? | ||
[ $retval -eq 0 ] && rm -f $lockfile | ||
return $retval | ||
} | ||
|
||
restart() { | ||
stop | ||
start | ||
} | ||
|
||
reload() { | ||
restart | ||
} | ||
|
||
force_reload() { | ||
restart | ||
} | ||
|
||
rh_status() { | ||
# run checks to determine if the service is running or use generic status | ||
status -p $PIDFILE -l $lockfile $prog | ||
} | ||
|
||
rh_status_q() { | ||
rh_status >/dev/null 2>&1 | ||
} | ||
|
||
|
||
case "$1" in | ||
start) | ||
rh_status_q && exit 0 | ||
$1 | ||
;; | ||
stop) | ||
rh_status_q || exit 0 | ||
$1 | ||
;; | ||
restart) | ||
$1 | ||
;; | ||
reload) | ||
rh_status || exit 7 | ||
$1 | ||
;; | ||
force-reload) | ||
force_reload | ||
;; | ||
status) | ||
rh_status | ||
;; | ||
condrestart|try-restart) | ||
rh_status || exit 0 | ||
restart | ||
;; | ||
*) | ||
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" | ||
exit 2 | ||
esac | ||
exit $? |
File renamed without changes.
30 changes: 30 additions & 0 deletions
30
src/main/resources/com/typesafe/sbt/packager/archetypes/upstart/start-rpm-template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# generated upstart config | ||
|
||
description "${{descr}}" | ||
author "${{author}}" | ||
|
||
# Stanzas | ||
# | ||
# Stanzas control when and how a process is started and stopped | ||
# See a list of stanzas here: http://upstart.ubuntu.com/wiki/Stanzas#respawn | ||
|
||
# When to start the service | ||
start on runlevel [2345] | ||
|
||
# When to stop the service | ||
stop on runlevel [016] | ||
|
||
# Automatically restart process if crashed. Tries ${{retries}} times every ${{retryTimeout}} seconds | ||
respawn | ||
respawn limit ${{retries}} ${{retryTimeout}} | ||
|
||
# set the working directory of the job processes | ||
chdir ${{chdir}} | ||
|
||
# changes to the user and group before running the job's process | ||
setuid ${{daemon_user}} | ||
|
||
# Start the process | ||
script | ||
exec ./bin/${{exec}} | ||
end script |
11 changes: 11 additions & 0 deletions
11
src/main/resources/com/typesafe/sbt/packager/rpm/postuninstall
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Adding system user/group : ${{daemon_user}} and ${{daemon_group}} | ||
if ! getent group | grep -q "^${{daemon_group}}:" ; | ||
then | ||
echo "Deleting system group: ${{daemon_group}}" | ||
groupdel ${{daemon_group}} | ||
fi | ||
if ! getent passwd | grep -q "^${{daemon_user}}:"; | ||
then | ||
echo "Deleting system user: ${{daemon_user}}" | ||
userdel ${{daemon_user}} | ||
fi |
11 changes: 11 additions & 0 deletions
11
src/main/resources/com/typesafe/sbt/packager/rpm/preinstall
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Adding system user/group : ${{daemon_user}} and ${{daemon_group}} | ||
if ! getent group | grep -q "^${{daemon_group}}:" ; | ||
then | ||
echo "Creating system group: ${{daemon_group}}" | ||
groupadd --system ${{daemon_group}} | ||
fi | ||
if ! getent passwd | grep -q "^${{daemon_user}}:"; | ||
then | ||
echo "Creating system user: ${{daemon_user}}" | ||
useradd --gid ${{daemon_group}} --no-create-home --system -c '${{descr}}' ${{daemon_user}} | ||
fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
:) We keep changing our minds here. Exec feels right as this should make the PID files line up.
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.
Yep, it should. We were all a bit confused (#168) However I'm with @kardapoltsev and we should put it back as this is the way to go.