Changeset View
Changeset View
Standalone View
Standalone View
devel/gogs/files/gogs-service.in
Show All 18 Lines | |||||
name="%%PORTNAME%%" | name="%%PORTNAME%%" | ||||
rcvar=%%PORTNAME%%_enable | rcvar=%%PORTNAME%%_enable | ||||
start_cmd="%%PORTNAME%%_start" | start_cmd="%%PORTNAME%%_start" | ||||
stop_cmd="%%PORTNAME%%_stop" | stop_cmd="%%PORTNAME%%_stop" | ||||
load_rc_config ${name} | load_rc_config ${name} | ||||
: ${%%PORTNAME%%_enable="NO"} | : ${%%PORTNAME%%_enable="NO"} | ||||
: ${%%PORTNAME%%_config="%%ETCDIR%%/conf/app.ini"} | |||||
is_process_running() { | is_process_running() { | ||||
local pidfile=$1 | local pidfile=$1 | ||||
[ -f $pidfile ] && procstat `cat $pidfile` >/dev/null 2>&1 | [ -f $pidfile ] && procstat `cat $pidfile` >/dev/null 2>&1 | ||||
} | } | ||||
stop_daemon() { | stop_daemon() { | ||||
# assume PID is also PGID (daemon(8) PID is always PGID) | # assume PID is also PGID (daemon(8) PID is always PGID) | ||||
[ -f "$1" ] && kill -- -$(cat $1) | [ -f "$1" ] && kill -- -$(cat $1) | ||||
} | } | ||||
%%PORTNAME%%_start() { | %%PORTNAME%%_start() { | ||||
local logfile=/var/log/%%PORTNAME%%.log | local logfile=/var/log/%%PORTNAME%%.log | ||||
local pidfile=/var/run/%%PORTNAME%%.pid | local pidfile=/var/run/%%PORTNAME%%.pid | ||||
if is_process_running $pidfile; then | if is_process_running $pidfile; then | ||||
echo "%%PORTNAME%% is already running (pid=$(cat $pidfile))" | echo "%%PORTNAME%% is already running (pid=$(cat $pidfile))" | ||||
return 1 | return 1 | ||||
fi | fi | ||||
export USER=%%GOGS_USER%% | export USER=%%GOGS_USER%% | ||||
export HOME=$(getent passwd %%GOGS_USER%% | cut -d: -f6) | export HOME=$(echo ~%%GOGS_USER%%) | ||||
touch $logfile | touch $logfile | ||||
chmod 640 $logfile | chmod 640 $logfile | ||||
cd %%PREFIX%%/libexec/%%PORTNAME%% | cd %%PREFIX%%/libexec/%%PORTNAME%% | ||||
/usr/sbin/daemon -P $pidfile -u %%GOGS_USER%% %%PREFIX%%/libexec/%%PORTNAME%%/%%PORTNAME%% web >>$logfile 2>&1 | /usr/sbin/daemon -P $pidfile -u %%GOGS_USER%% %%PREFIX%%/libexec/%%PORTNAME%%/%%PORTNAME%% web --config ${%%PORTNAME%%_config} >>$logfile 2>&1 | ||||
if is_process_running $pidfile; then | if is_process_running $pidfile; then | ||||
echo "started %%PORTNAME%% (pid=$(cat $pidfile))" | echo "started %%PORTNAME%% (pid=$(cat $pidfile))" | ||||
else | else | ||||
echo "failed to start %%PORTNAME%%" | echo "failed to start %%PORTNAME%%" | ||||
fi | fi | ||||
} | } | ||||
%%PORTNAME%%_stop() { | %%PORTNAME%%_stop() { | ||||
Show All 12 Lines |