aboutsummaryrefslogtreecommitdiffstats
path: root/devel/hadoop/files/tasktracker.in
blob: ee99429f3698d9026a3f1228ccbe71c007dae3e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: tasktracker
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable this service:
#
# tasktracker_enable (bool):     Set to NO by default.
#                                Set it to YES to enable tasktracker.
# tasktracker_user (str):        Set to %%MAPRED_USER%% by default.
#                                Set to a valid user to change default 
#                                tasktracker user.
# tasktracker_java_home (str):   Unset by default.
#                                Switch to another JVM.
#
# tasktracker_log_dir (str):     Unset by default.
# tasktracker_pid_dir (str):     Unset by default.
#

. /etc/rc.subr

name=tasktracker
rcvar=tasktracker_enable

load_rc_config "${name}"

: ${tasktracker_enable:=NO}
: ${tasktracker_user:=%%MAPRED_USER%%}
: ${tasktracker_group:=%%HADOOP_GROUP%%}

command="%%DATADIR%%/bin/hadoop-daemon.sh"
command_args='--config ${HADOOP_CONF_DIR} start tasktracker'

start_precmd=tasktracker_init
stop_precmd=tasktracker_init
stop_cmd=tasktracker_stop


tasktracker_init()
{
    if [ -n "${tasktracker_java_home}" ]
    then
        export JAVA_HOME="${tasktracker_java_home}"
    fi

    for f in %%ETCDIR%%/envvars.d/*.env
    do
        . ${f}
    done
    if [ -n "${tasktracker_log_dir}" ]
    then
        HADOOP_LOG_DIR=${tasktracker_log_dir}
    fi      

    if [ -n "${tasktracker_pid_dir}" ]
    then
        HADOOP_LOG_DIR=${tasktracker_pid_dir}
    fi      

    install -d -m 755 -o ${tasktracker_user} -g ${tasktracker_group} ${HADOOP_PID_DIR}
    install -d -m 755 -o ${tasktracker_user} -g ${tasktracker_group} ${HADOOP_LOG_DIR}
}

tasktracker_stop ()
{
    su -m ${tasktracker_user} -c "${command} --config ${HADOOP_CONF_DIR} stop tasktracker"
}

run_rc_command "$1"