Skip to content

Commit

Permalink
Merge pull request #23 from ggtakec/fix_devstack
Browse files Browse the repository at this point in the history
Updated devpack.sh for trove and removed run_node_helper.sh
  • Loading branch information
ggtakec authored Jul 13, 2022
2 parents 07c69e0 + 676d07d commit 5fceb56
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 63 deletions.
36 changes: 28 additions & 8 deletions devpack/bin/devpack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ if [ "X${OPT_NO_INTERACTIVE}" != "Xyes" ]; then
fi
else
if [ "X${OPT_RUNUSER}" = "X" ]; then
#OPT_RUNUSER="nobody"
OPT_RUNUSER="root"
#OPT_RUNUSER="root"
OPT_RUNUSER="nobody"
fi
if [ "X${OPT_CHMPX_SERVER_PORT}" = "X" ]; then
OPT_CHMPX_SERVER_PORT=18020
Expand Down Expand Up @@ -819,6 +819,13 @@ if [ $? -ne 0 ]; then
exit 1
fi

# for npm log directory
chmod 0777 ~/.npm/_logs
if [ $? -ne 0 ]; then
echo "${CRED}${CREV}[ERROR]${CDEF}${CRED} could not change permission ~/.npm/_logs directory${CDEF}" 1>&2
exit 1
fi

echo "${CGRN}${CREV}[SUCCESS]${CDEF}${CGRN} Setup and Generated K2HR3 REST API configuration files : ${SRCTOP}/k2hr3-api/config/production.json${CDEF}"

#----------------------------------------------------------
Expand Down Expand Up @@ -926,6 +933,13 @@ if [ $? -ne 0 ]; then
exit 1
fi

# for npm log directory(maybe already set by k2hr3 api setting)
chmod 0777 ~/.npm/_logs
if [ $? -ne 0 ]; then
echo "${CRED}${CREV}[ERROR]${CDEF}${CRED} could not change permission ~/.npm/_logs directory${CDEF}" 1>&2
exit 1
fi

echo "${CGRN}${CREV}[SUCCESS]${CDEF}${CGRN} Setup and Generated K2HR3 Application configuration files : ${SRCTOP}/k2hr3-app/config/production.json${CDEF}"

#----------------------------------------------------------
Expand Down Expand Up @@ -961,6 +975,7 @@ echo ""
echo "-----------------------------------------------------------"
echo "${CGRN}Start all processes${CDEF}"
echo "-----------------------------------------------------------"
cd ${SRCTOP}

echo "${CGRN}${CREV}[RUN]${CDEF} CHMPX server node..."
sudo -u ${OPT_RUNUSER} chmpx -conf ${SRCTOP}/conf/server.ini -d err >> ${SRCTOP}/log/chmpx_server.log 2>&1 &
Expand Down Expand Up @@ -993,26 +1008,31 @@ sleep 20

#
# [NOTE]
# Nodejs will be started as root, but internally it will be setuid and run as nobody.
# In k2hr3, log files and directories are created as root, which causes permission issues.
# rotating-file-stream(and fs.createWriteStream, etc.) has a mode option, but which doesn't work.
# Therefore, we use helper script for sudo and umask.
# When k2hr3_api and k2hr3_app starts the node process, it gets the
# execution user from config and executes setuid.
# Then we want to start Nodejs as nobody to support it, but we can't
# run the npm command with root privileges using sudo.
# So run npm here as "sudo -u nobody", it run npm as nobody user
# instead of root directly.
#
echo "${CGRN}${CREV}[RUN]${CDEF} K2HR3 REST API..."
sudo ${BINDIR}/run_node_helper.sh ${SRCTOP}/k2hr3-api
cd ${SRCTOP}/k2hr3-api
sudo -u ${OPT_RUNUSER} npm run start
wait_process_running www k2hr3-api 20 3
if [ $? -ne 0 ]; then
echo "${CRED}${CREV}[ERROR]${CDEF}${CRED} Could not run k2hr3-api node process${CDEF}" 1>&2
exit 1
fi

echo "${CGRN}${CREV}[RUN]${CDEF} K2HR3 Application..."
sudo ${BINDIR}/run_node_helper.sh ${SRCTOP}/k2hr3-app
cd ${SRCTOP}/k2hr3-app
sudo -u ${OPT_RUNUSER} npm run start
wait_process_running www k2hr3-app 20 3
if [ $? -ne 0 ]; then
echo "${CRED}${CREV}[ERROR]${CDEF}${CRED} Could not run k2hr3-app node process${CDEF}" 1>&2
exit 1
fi
cd ${SRCTOP}

#----------------------------------------------------------
# Success
Expand Down
55 changes: 0 additions & 55 deletions devpack/bin/run_node_helper.sh

This file was deleted.

0 comments on commit 5fceb56

Please sign in to comment.