added rc init script for lingyind Flask app

This commit is contained in:
gashapwn 2020-11-30 04:29:02 +00:00
parent cd6720a25e
commit 9575aecb4e
2 changed files with 25 additions and 1 deletions

View File

@ -0,0 +1,17 @@
#!/bin/ksh
#
# lingyind
daemon="cd /tilde/lyadmin/ && . /tilde/lyadmin/venv/bin/activate && python3 /tilde/lyadmin/app.py &"
daemon_user="lingyind"
. /etc/rc.d/rc.subr
pexp="python3 /tilde/lyadmin/app.py"
rc_reload=NO
rc_stop() {
pkill -f "^${pexp}"
}
rc_cmd $1

View File

@ -71,6 +71,11 @@ printf("generating virtual enviornment...\n");
system("su $SVC_ACCT -c 'python3 -m venv venv'");
system("su $SVC_ACCT -c '. ./venv/bin/activate && pip3 install -r requirements.txt'");
system("cp ./perl-script/conf/lingyin.rc /etc/rc.d/lingyind");
system("chmod 755 /etc/rc.d/lingyind");
system("rcctl enable lingyind");
system("rcctl start lingyind");
system("pkg_add p5-JSON");
# Install apache
@ -95,14 +100,16 @@ system("sed -i -e 's/\\(<\\/Directory>\\)/ Options -Indexes\\
# Change the port to 5001
system("sed -i -e 's/^\\(.\\)*Listen *80/\\1Listen 5001/' /etc/apache2/httpd2.conf");
# rev up those apache processes!
system("rcctl enable apache2");
system("rcctl start apache2");
# Install and config haproxy
system("pkg_add haproxy");
printf("configuring haproxy\n");
system("cp ./perl-script/conf/haproxy.cfg /etc/haproxy/haproxy.cfg");
system("rcctl enable haproxy");
system("rcctl start haproxy");
printf("dont forget to setup your ssh pub key at /home/$admin_un/.ssh/authorized_keys\n");