X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic_server_cli.cc;h=f35797954ae907ff237146c2480ecc3289574bff;hb=9a2b45caa81d8fb056802dfe3c25f214e808ffdf;hp=76d0850341619c9638861e27538ee7f22285ea5b;hpb=f861018389acd9d277fe34d7621182b9b54f977f;p=dcpomatic.git diff --git a/src/tools/dcpomatic_server_cli.cc b/src/tools/dcpomatic_server_cli.cc index 76d085034..f35797954 100644 --- a/src/tools/dcpomatic_server_cli.cc +++ b/src/tools/dcpomatic_server_cli.cc @@ -20,7 +20,6 @@ #include "lib/server.h" #include #include -#include #include #include #include @@ -32,15 +31,15 @@ #include #include #include -#include "config.h" -#include "dcp_video_frame.h" -#include "exceptions.h" -#include "util.h" -#include "config.h" -#include "scaler.h" -#include "image.h" -#include "log.h" -#include "version.h" +#include "lib/config.h" +#include "lib/dcp_video_frame.h" +#include "lib/exceptions.h" +#include "lib/util.h" +#include "lib/config.h" +#include "lib/scaler.h" +#include "lib/image.h" +#include "lib/log.h" +#include "lib/version.h" using std::cerr; using std::string; @@ -53,24 +52,30 @@ help (string n) cerr << "Syntax: " << n << " [OPTION]\n" << " -v, --version show DCP-o-matic version\n" << " -h, --help show this help\n" - << " -t, --threads number of parallel encoding threads to use\n"; + << " -t, --threads number of parallel encoding threads to use\n" + << " --verbose be verbose to stdout\n" + << " --log write a log file of activity\n"; } int main (int argc, char* argv[]) { int num_threads = Config::instance()->num_local_encoding_threads (); + bool verbose = false; + bool write_log = false; int option_index = 0; - while (1) { + while (true) { static struct option long_options[] = { { "version", no_argument, 0, 'v'}, { "help", no_argument, 0, 'h'}, { "threads", required_argument, 0, 't'}, + { "verbose", no_argument, 0, 'A'}, + { "log", no_argument, 0, 'B'}, { 0, 0, 0, 0 } }; - int c = getopt_long (argc, argv, "vht:", long_options, &option_index); + int c = getopt_long (argc, argv, "vht:AB", long_options, &option_index); if (c == -1) { break; @@ -86,12 +91,33 @@ main (int argc, char* argv[]) case 't': num_threads = atoi (optarg); break; + case 'A': + verbose = true; + break; + case 'B': + write_log = true; + break; } } Scaler::setup_scalers (); - shared_ptr log (new FileLog ("servomatic.log")); - Server server (log); - server.run (num_threads); + shared_ptr log; + if (write_log) { + log.reset (new FileLog ("dcpomatic_server_cli.log")); + } else { + log.reset (new NullLog); + } + + Server server (log, verbose); + + try { + server.run (num_threads); + } catch (boost::system::system_error e) { + if (e.code() == boost::system::errc::address_in_use) { + cerr << argv[0] << ": address already in use. Is another DCP-o-matic server instance already running?\n"; + exit (EXIT_FAILURE); + } + cerr << argv[0] << ": " << e.what() << "\n"; + } return 0; }