Skip to content

Commit

Permalink
Merge pull request #363 from Expensify/sam_xenial_build_config
Browse files Browse the repository at this point in the history
Update bedrock config files for Ubuntu 14.04 and 16.04 - reviewed, merging
  • Loading branch information
coleaeason authored Feb 22, 2018
2 parents ec06209 + 225ef1b commit 930446d
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 5 deletions.
28 changes: 28 additions & 0 deletions configs/bedrock.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Bedrock default config file.
# Run `bedrock -?` for help with command line arguments

# Path of db file; will be created if absent
BEDROCK_DB_PATH="/var/lib/bedrock/bedrock.db"

# If running a cluster, these values need to be different for each node.
THISNODE="bedrock"
PRIORITY=200

# Cache size in kilobytes. Default: 1GB
CACHE_SIZE="-cacheSize 10000"

# Bind to network address
SERVER_HOST="0.0.0.0:8888"
NODE_HOST="0.0.0.0:8889"

# Number of worker threads. Default: # of CPUs on the system.
# WORKER_THREADS="-workerThreads 1"

# Select which plugins to run. Default: db,jobs,cache
# PLUGINS="-plugins db,jobs,cache"

# If running a cluster, uncomment to enable.
# PEER_LIST="-peerList node1,node2"

# Use '-v' for verbose or '-q' for quiet. Omit this option for standard log level.
# LOG_LEVEL="-v"
4 changes: 2 additions & 2 deletions configs/bedrock.init
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if [ -n "$OTHERNODES" ]; then
FLAGS="-peerList $OTHERNODES"
fi

DAEMON_OPTS="-fork -nodeName $THISNODE -db $BEDROCK_DB_PATH -serverHost 0.0.0.0:8888 -nodeHost 0.0.0.0:8889 -priority $PRIORITY -pidfile $PIDFILE -quorumCheckpoint 100 -readThreads 4 -plugins status,db,jobs,cache,mysql $FLAGS"
DAEMON_OPTS="-fork -nodeName $THISNODE -db $BEDROCK_DB_PATH -serverHost 0.0.0.0:8888 -nodeHost 0.0.0.0:8889 -priority $PRIORITY -pidfile $PIDFILE $FLAGS"

if ! [[ -x $BIN ]]; then echo "$1: Job failed! Missing or broken binary file: $BIN" && exit 2; fi
set -e
Expand All @@ -56,7 +56,7 @@ case "$1" in
fi
if [ ! -f $BEDROCK_DB_PATH ]; then
log_daemon_msg "No db found, creating db."
if ! touch $BEDROCK_DB_PATH; then
if ! touch $BEDROCK_DB_PATH; then
log_end_msg 1
else
log_end_msg 0
Expand Down
31 changes: 31 additions & 0 deletions configs/bedrock.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[Unit]
Description=Expensify Bedrock Server
Documentation=http://bedrockdb.com/
After=network.target

# The following creates the database file if absent
After=bedrock_prerequisites.service
Requires=bedrock_prerequisites.service

[Service]
EnvironmentFile=/etc/bedrock/bedrock.conf
PIDFile=/var/run/bedrock.pid

Type=forking

ExecStart=/usr/sbin/bedrock \
-fork \
-pidFile /var/run/bedrock.pid \
-nodeName ${THISNODE} \
-db ${BEDROCK_DB_PATH} \
-serverHost ${SERVER_HOST} \
-nodeHost ${NODE_HOST} \
-priority ${PRIORITY} \
${PLUGINS} \
${WORKER_THREADS} \
${CACHE_SIZE} \
${PEER_LIST} \
${LOG_LEVEL}

ExecStop=/bin/kill -TERM $MAINPID
KillMode=process
11 changes: 11 additions & 0 deletions configs/bedrock_prerequisites.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Generates prerequisite files for bedrock.service, if absent
Documentation=http://bedrockdb.com/

[Service]
Type=oneshot
EnvironmentFile=/etc/bedrock/bedrock.conf

# The following creates database dir and database file
ExecStart=/bin/sh -c 'mkdir -p "$(dirname "${BEDROCK_DB_PATH}")"'
ExecStart=/bin/sh -c 'test -f "${BEDROCK_DB_PATH}" || touch "${BEDROCK_DB_PATH}"'
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ int main(int argc, char* argv[]) {
cout << "-nodeHost <host:port> Listen on this host:port for connections from other nodes" << endl;
cout << "-peerList <list> See below" << endl;
cout << "-priority <value> See '-peerList Details' below (defaults to 100)" << endl;
cout << "-plugins <list> Enable these plugins (defaults to 'db,jobs,cache')" << endl;
cout << "-plugins <list> Enable these plugins (defaults to 'db,jobs,cache,mysql')" << endl;
cout << "-cacheSize <kb> number of KB to allocate for a page cache (defaults to 1GB)" << endl;
cout << "-workerThreads <#> Number of worker threads to start (min 1, defaults to # of cores)" << endl;
cout << "-queryLog <filename> Set the query log filename (default 'queryLog.csv', SIGUSR2/SIGQUIT to "
Expand Down Expand Up @@ -269,7 +269,7 @@ int main(int argc, char* argv[]) {
SETDEFAULT("-controlPort", "localhost:9999");
SETDEFAULT("-nodeName", SGetHostName());
SETDEFAULT("-cacheSize", SToStr(1024 * 1024)); // 1024 * 1024KB = 1GB.
SETDEFAULT("-plugins", "db,jobs,cache");
SETDEFAULT("-plugins", "db,jobs,cache,mysql");
SETDEFAULT("-priority", "100");
SETDEFAULT("-maxJournalSize", "1000000");
SETDEFAULT("-queryLog", "queryLog.csv");
Expand Down
1 change: 0 additions & 1 deletion plugins/MySQL.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ class BedrockPlugin_MySQL : public BedrockPlugin {
virtual string getName() { return "MySQL"; }
virtual void initialize(const SData& args, BedrockServer& server) { _args = args; }
virtual string getPort() {
SWARN("ARGS: " << _args.serialize());
return _args.isSet("-mysql.host") ? _args["-mysql.host"] : "localhost:3306";
}
virtual void onPortAccept(STCPManager::Socket* s);
Expand Down

0 comments on commit 930446d

Please sign in to comment.