added status

Added status and reordered the script.
This commit is contained in:
Jordan Ostreff 2022-10-21 19:44:48 +03:00 committed by GitHub
parent b6c0333783
commit 57cf1f8a09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

22
pm2
View file

@ -7,8 +7,6 @@
# Download this file # Download this file
# cd /usr/local/etc/rc.d && fetch https://gist.github.com/457769f2090c6b69cd9d # cd /usr/local/etc/rc.d && fetch https://gist.github.com/457769f2090c6b69cd9d
# #
# Source: https://ostreff.info/pm2-rcd
# Modifications to use sudo by: Jordan Ostreff
# Download this file # Download this file
# cd /usr/local/etc/rc.d && fetch https://raw.githubusercontent.com/jostreff/ghost-rc.d-script/main/pm2 -o pm2 # cd /usr/local/etc/rc.d && fetch https://raw.githubusercontent.com/jostreff/ghost-rc.d-script/main/pm2 -o pm2
# #
@ -20,30 +18,28 @@
# pm2_enable="YES" # pm2_enable="YES"
# pm2_user="ghost" # pm2_user="ghost"
# #
# PROVIDE: pm2
# REQUIRE: NETWORK mongod mysql-server
# KEYWORD: shutdown # KEYWORD: shutdown
# #
. /etc/rc.subr . /etc/rc.subr
export PATH=$PATH:/usr/local/bin : ${pm2_user="ghost"}
export NODE_ENV="production" : ${pm2_enable="NO"}
name=pm2 name=pm2
rcvar=pm2_enable rcvar=pm2_enable
export PATH=$PATH:/usr/local/bin
export NODE_ENV="production"
PM2=/usr/local/lib/node_modules/pm2/bin/pm2 PM2=/usr/local/lib/node_modules/pm2/bin/pm2
load_rc_config $name load_rc_config $name
extra_commands="status"
start_cmd="pm2_start" start_cmd="pm2_start"
stop_cmd="pm2_stop" stop_cmd="pm2_stop"
restart_cmd="pm2_reload" restart_cmd="pm2_reload"
describe_cmd="pm2_ls" describe_cmd="pm2_ls"
status_cmd="pm2_show"
: ${pm2_user="ghost"}
: ${pm2_enable="NO"}
pm2_start() pm2_start()
{ {
@ -67,6 +63,12 @@ pm2_ls()
/usr/local/bin/sudo -u ${pm2_user} -s ${CMD} /usr/local/bin/sudo -u ${pm2_user} -s ${CMD}
} }
pm2_show()
{
CMD="${PM2} show 0"
/usr/local/bin/sudo -u ${pm2_user} -s ${CMD}
}
pm2_reload() pm2_reload()
{ {
CMD="$PM2 reload all" CMD="$PM2 reload all"