forked from NodeBB/NodeBB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodebb
executable file
·136 lines (120 loc) · 3.11 KB
/
nodebb
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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
# $0 script path
# $1 action
# $2 subaction
node="$(which nodejs 2>/dev/null)";
if [ $? -gt 0 ];
then node="$(which node)";
fi
function pidExists() {
if [ -e "pidfile" ];
then
if ps -p $(cat pidfile) > /dev/null
then return 1;
else
rm ./pidfile;
return 0;
fi
else
return 0;
fi
}
case "$1" in
start)
echo "Starting NodeBB";
echo " \"./nodebb stop\" to stop the NodeBB server";
echo " \"./nodebb log\" to view server output";
# Start the loader daemon
"$node" loader "$@"
;;
stop)
pidExists;
if [ 0 -eq $? ];
then
echo "NodeBB is already stopped.";
else
echo "Stopping NodeBB. Goodbye!";
kill $(cat pidfile);
fi
;;
restart)
pidExists;
if [ 0 -eq $? ];
then
echo "NodeBB could not be restarted, as a running instance could not be found.";
else
echo "Restarting NodeBB.";
kill -1 $(cat pidfile);
fi
;;
reload)
pidExists;
if [ 0 -eq $? ];
then
echo "NodeBB could not be reloaded, as a running instance could not be found.";
else
echo "Reloading NodeBB.";
kill -12 $(cat pidfile);
fi
;;
status)
pidExists;
if [ 0 -eq $? ];
then
echo "NodeBB is not running";
echo " \"./nodebb start\" to launch the NodeBB server";
else
echo "NodeBB Running (pid $(cat pidfile))";
echo " \"./nodebb stop\" to stop the NodeBB server";
echo " \"./nodebb log\" to view server output";
echo " \"./nodebb restart\" to restart NodeBB";
fi
;;
log)
clear;
tail -F ./logs/output.log;
;;
upgrade)
npm install
# ls -d node_modules/nodebb* | xargs -n1 basename | xargs npm install
# ls -d node_modules/nodebb* | xargs -n1 basename | xargs npm update
npm i nodebb-theme-vanilla nodebb-theme-lavender nodebb-widget-essentials
"$node" app --upgrade
touch package.json
;;
setup)
"$node" app --setup "$@"
;;
reset)
"$node" app --reset --$2
;;
dev)
echo "Launching NodeBB in \"development\" mode."
echo "To run the production build of NodeBB, please use \"forever\"."
echo "More Information: https://docs.nodebb.org/en/latest/running/index.html"
NODE_ENV=development "$node" loader --no-daemon "$@"
;;
watch)
echo "Launching NodeBB in \"development\" mode."
echo "To run the production build of NodeBB, please use \"forever\"."
echo "More Information: https://docs.nodebb.org/en/latest/running/index.html"
NODE_ENV=development supervisor -q --ignore public/templates,public/nodebb.min.js,public/nodebb.min.js.map --extensions 'node|js|tpl|less' -- app "$@"
;;
*)
echo "Welcome to NodeBB"
echo $"Usage: $0 {start|stop|reload|restart|log|setup|reset|upgrade|dev|watch}"
echo ''
column -s ' ' -t <<< '
start Start the NodeBB server
stop Stops the NodeBB server
reload Restarts NodeBB
restart Restarts NodeBB
log Opens the logging interface (useful for debugging)
setup Runs the NodeBB setup script
reset Disables all plugins, restores the default theme.
upgrade Run NodeBB upgrade scripts, ensure packages are up-to-date
dev Start NodeBB in interactive development mode
watch Start NodeBB in development mode and watch for changes
'
exit 1
esac