FreeBSD

MongoDB

placeholder

Installing Petio

There is no package built for FreeBSD so the application will have to be built from source

Building from source

1
## Install dependencies
2
pkg install mongodb
3
pkg install npm
4
pkg install git (only if you want to use git to checkout the source)
5
npm install -g typescript
6
7
## Clone the repo and build the application
8
mkdir -p /usr/local/share/petio
9
cd /usr/local/share/petio
10
git clone -b dev https://github.com/petio-team/petio.git .
11
cd pkg/admin
12
npm install
13
npm run build
14
cd ../frontend
15
npm install
16
npm run build
17
cd ../api
18
npm install
19
npm run build
20
cd
21
mkdir -p /usr/local/petio
22
chown $petio_user:$petio_group /usr/local/petio
23
su -m $petio_user
24
setenv VIEWS_FOLDER /usr/local/share/petio/pkg/
25
setenv DATA_FOLDER /usr/local/petio
26
27
# Run the application
28
node /usr/local/share/petio/pkg/api/dist/main.js --host 0.0.0.0 --port 7777
Copied!

Create a Petio service

rc.d script to run petio. It checks whether mongod is enabled and running, warns if not, and forcefully starts it if not running.
  • Place this script in /usr/local/etc/rc.d/petio
  • Give it execute permissions: chmod +x /usr/local/etc/rc.d/petio
  • Configure it in /etc/rc.conf
    • sysrc petio_enable="YES"
    • optionally set user: sysrc petio_user="petio"
    • optionally set group: sysrc petio_group="petio"
    • optionally set data directory: sysrc petio_data_dir="/usr/local/petio"
1
#!/bin/sh
2
3
# PROVIDE: petio
4
# REQUIRE: DAEMON mongod
5
# BEFORE: LOGIN
6
# KEYWORD: shutdown
7
8
. /etc/rc.subr
9
10
name=petio
11
rcvar=petio_enable
12
13
load_rc_config $name
14
15
: ${petio_enable:="NO"}
16
: ${petio_user:="petio"}
17
: ${petio_group:="petio"}
18
: ${petio_data_dir:="/usr/local/petio"}
19
20
export NODE_ENV=production
21
export APP_DIR=/usr/local/share/petio
22
export VIEWS_FOLDER=/usr/local/share/petio/pkg/
23
export DATA_FOLDER=${petio_data_dir}
24
25
pidfile="/var/run/${name}/${name}.pid"
26
start_precmd="petio_precmd"
27
28
procname="/usr/local/bin/node"
29
command="/usr/sbin/daemon"
30
command_args="-f -p ${pidfile} ${procname} --no-warnings /usr/local/share/petio/pkg/api/dist/main.js --host 0.0.0.0 --port 7777"
31
32
petio_precmd()
33
{
34
if [ ! -d $(dirname ${pidfile}) ]; then
35
install -d -o ${petio_user} -g ${petio_group} $(dirname ${pidfile})
36
fi
37
38
if [ ! -d ${petio_data_dir} ]; then
39
install -d -o ${petio_user} -g ${petio_group} ${petio_data_dir}
40
fi
41
42
# make sure mongod is running
43
if ! checkyesno mongod_enable && \
44
! /usr/local/etc/rc.d/mongod forcestatus 1>/dev/null 2>&1; then
45
echo "Make sure to enable and start mongod"
46
/usr/local/etc/rc.d/mongod forcestart || return 1
47
fi
48
return 0
49
}
50
51
run_rc_command "$1"
Copied!
Once you've completed these steps, you can navigate to http://<hostname>:7777 to start configuring Petio.
Copy link