0xGA: Check-in [f68d80e7b3]

Yet another PHP framework, but made for org-mode and geeks.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Shiny messages wrapper for start and stop functions
Timelines: family | ancestors | descendants | both | narv
Files: files | file ages | folders
SHA1:f68d80e7b32666f2cd4cf2c4d674f108fbfd8f9f
User & Date: milouse 2014-06-02 11:32:52
Context
2014-06-12
18:10
Fix bad emacs regexps in narv project creation file check-in: a70702b6fe user: milouse tags: narv
2014-06-02
11:32
Shiny messages wrapper for start and stop functions check-in: f68d80e7b3 user: milouse tags: narv
2014-05-21
23:45
Fix serious bug in blog path management and sqlite find_all request check-in: 01237bba82 user: milouse tags: narv
Changes

Changes to narv.

1
2
3
4
5
6
7



















8
9
10
11
12
13
14
..
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
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash

if ! which python3 &> /dev/null ; then
    echo "You must have python3 installed on your computer to use Narv."
    exit 1
fi




















function usage_help {
    cat <<EOF
Narv - Tiny org-mode file server

Platform: `uname -o` `uname -r`; `python3 --version`

Usage: $0 [command] [args] <appname>
................................................................................
        exit 1;
    elif pgrep -f $APPNAME.py >/dev/null ; then
        pgrep -f $APPNAME.py > $WORKINGREP/var/$APPNAME.pid
        echo "Your Narv application seems to be always running. Try $0 stop $APPNAME"
        exit 1;
    fi

    echo -n "Starting $WORKINGREP/usr/bin/$APPNAME.py"
    $WORKINGREP/usr/bin/$APPNAME.py &
    pgrep -f $APPNAME.py > $WORKINGREP/var/$APPNAME.pid
    echo "                   [OK]"
}

function narv_stop {
    if [ ! -f "$WORKINGREP/var/$APPNAME.pid" ] ; then
        echo "Your Narv application is NOT running."
        exit 1;
    fi
    echo -n "Stopping $WORKINGREP/usr/bin/$APPNAME.py"
    pkill -f $APPNAME.py
    rm $WORKINGREP/var/$APPNAME.pid
    sleep 2
    if pgrep -f $APPNAME.py >/dev/null ; then
        yup=no

        while [ "$yup" != "yes" ] ; do
            sleep 5

            if pgrep -f $APPNAME.py >/dev/null ; then








                echo
                echo -n "$APPNAME.py does not respond... Kill violently (yes|r[etry]|no)? "
                read yup
                if [ "$yup" = "r" -o "$yup" = "retry" ] ; then
                    pkill -f $APPNAME.py
                fi
            else
                echo "[OK... finally]"
                exit 0
            fi
        done
        pkill -9 -f $APPNAME.py
        echo "Aaaoooww :s"
        exit $?
    fi
    echo "                   [OK]"
}

function narv_restart {
    if [ ! -f "$WORKINGREP/var/$APPNAME.pid" ] ; then
        echo "Your Narv application is NOT running."
        exit 1;
    fi







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|


|







|


<


>

|
>

>
>
>
>
>
>
>
>






<
<
<






|







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
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94



95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash

if ! which python3 &> /dev/null ; then
    echo "You must have python3 installed on your computer to use Narv."
    exit 1
fi


DAEMON_CURRENT_LINE=''
function daemon_begin_log_line {
    DAEMON_CURRENT_LINE="$1"
    echo -n "$DAEMON_CURRENT_LINE"
}
function daemon_waiter_log {
    echo -n " $1"
}
function daemon_end_log_line {
    echo -ne "\r$DAEMON_CURRENT_LINE"

    if [ "$1" = "0" ]; then
        printf "%*s\n" $(($(tput cols) - ${#DAEMON_CURRENT_LINE})) "[ok]"
    else
        printf "%*s\n" $(($(tput cols) - ${#DAEMON_CURRENT_LINE})) "[error]"
    fi
}

function usage_help {
    cat <<EOF
Narv - Tiny org-mode file server

Platform: `uname -o` `uname -r`; `python3 --version`

Usage: $0 [command] [args] <appname>
................................................................................
        exit 1;
    elif pgrep -f $APPNAME.py >/dev/null ; then
        pgrep -f $APPNAME.py > $WORKINGREP/var/$APPNAME.pid
        echo "Your Narv application seems to be always running. Try $0 stop $APPNAME"
        exit 1;
    fi

    daemon_begin_log_line "Starting $WORKINGREP/usr/bin/$APPNAME.py"
    $WORKINGREP/usr/bin/$APPNAME.py &
    pgrep -f $APPNAME.py > $WORKINGREP/var/$APPNAME.pid
    daemon_end_log_line 0
}

function narv_stop {
    if [ ! -f "$WORKINGREP/var/$APPNAME.pid" ] ; then
        echo "Your Narv application is NOT running."
        exit 1;
    fi
    daemon_begin_log_line "Stopping $WORKINGREP/usr/bin/$APPNAME.py"
    pkill -f $APPNAME.py
    rm $WORKINGREP/var/$APPNAME.pid

    if pgrep -f $APPNAME.py >/dev/null ; then
        yup=no
        count=0
        while [ "$yup" != "yes" ] ; do
            sleep 1
            daemon_waiter_log "."
            if pgrep -f $APPNAME.py >/dev/null ; then
                let "count=$count+1"
            else
                daemon_end_log_line 0
                exit 0
            fi

            if [ "$count" = "10" ]; then
                count=0
                echo
                echo -n "$APPNAME.py does not respond... Kill violently (yes|r[etry]|no)? "
                read yup
                if [ "$yup" = "r" -o "$yup" = "retry" ] ; then
                    pkill -f $APPNAME.py
                fi



            fi
        done
        pkill -9 -f $APPNAME.py
        echo "Aaaoooww :s"
        exit $?
    fi
    daemon_end_log_line 0
}

function narv_restart {
    if [ ! -f "$WORKINGREP/var/$APPNAME.pid" ] ; then
        echo "Your Narv application is NOT running."
        exit 1;
    fi