Commit 4736ef93 authored by Seblu's avatar Seblu
Browse files

Ajout script de creation de l'env de test

Ajout d'une deuxieme base de test
Gestion de l'env dans les options
Print des options au demarrage
Ajout des fichiers du scheduleurs
parent 9214f0eb
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -24,6 +24,8 @@ sls_SOURCES= src/sls.hh \
		src/option.cc		\
		src/option.cc		\
		src/database.hh		\
		src/database.hh		\
		src/database.cc		\
		src/database.cc		\
		src/cron.hh		\
		src/cron.cc		\
		src/server.hh		\
		src/server.hh		\
		src/server.cc
		src/server.cc


sls/trunk/src/cron.cc

0 → 100644
+20 −0
Original line number Original line Diff line number Diff line
/*
  This file is part of SLS.
  Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net>

  SLS is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; version 2 of the License.

  SLS is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with SLS; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include "sls.hh"
#include "cron.hh"

sls/trunk/src/cron.hh

0 → 100644
+22 −0
Original line number Original line Diff line number Diff line
/*
  This file is part of SLS.
  Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net>

  SLS is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; version 2 of the License.

  SLS is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with SLS; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#ifndef CRON_HH
# define CRON_HH

#endif
+44 −23
Original line number Original line Diff line number Diff line
@@ -29,9 +29,8 @@ Option::Option() {
  verbose = false;
  verbose = false;
  database = "/var/db/sls.db";
  database = "/var/db/sls.db";
  port = 18136;
  port = 18136;
  maxthread = 200;
  maxconn = 200;
  daemon = true;
  daemon = true;
  closefd = true;
  logfile = "/var/log/sls";
  logfile = "/var/log/sls";
  pidfile = "/var/lock/sls.pid";
  pidfile = "/var/lock/sls.pid";
}
}
@@ -47,11 +46,10 @@ void Option::usage(const char *name, ostream &out) const {
      << "-v | --verbose        : Set verbose mode." << std::endl
      << "-v | --verbose        : Set verbose mode." << std::endl
      << "-V | --version        : Print version and exit." << std::endl
      << "-V | --version        : Print version and exit." << std::endl
      << "-p | --port p         : sls listen on port p (def: 18136)." << std::endl
      << "-p | --port p         : sls listen on port p (def: 18136)." << std::endl
      << "-t | --max-thread p   : Maximun number of thread (def: 200)." << std::endl
      << "-m | --max-conn p     : Maximun number of connection (def: 200)." << std::endl
      << "-P | --pid-file       : Path to pid file (def: /var/lock/sls.pid)." << std::endl
      << "-P | --pid-file       : Path to pid file (def: /var/lock/sls.pid)." << std::endl
      << "-l | --log-file       : Path to log file (def: /var/log/sls)." << std::endl
      << "-l | --log-file       : Path to log file (def: /var/log/sls)." << std::endl
      << "-D | --debug          : Run with verbose and not in daemon mode." << std::endl
      << "-D | --debug          : Run with verbose and not in daemon mode." << std::endl;
      << "-n | --no-close       : Don't close stdin,stdout and stderr." << std::endl;
}
}


/*!
/*!
@@ -69,16 +67,15 @@ Option &Option::load(int argc, char *argv[]) {
    {"verbose", 0, 0, 'v'},
    {"verbose", 0, 0, 'v'},
    {"version", 0, 0, 'V'},
    {"version", 0, 0, 'V'},
    {"port", 0, 0, 'p'},
    {"port", 0, 0, 'p'},
    {"max-thread", 0, 0, 't'},
    {"max-conn", 0, 0, 'm'},
    {"pid-file", 0, 0, 'P'},
    {"pid-file", 0, 0, 'P'},
    {"log-file", 0, 0, 'l'},
    {"log-file", 0, 0, 'l'},
    {"debug", 0, 0, 'D'},
    {"debug", 0, 0, 'D'},
    {"no-close", 0, 0, 'n'},
    {0, 0, 0, 0},
    {0, 0, 0, 0},
  };
  };
  int option;
  int option;


  while ((option = getopt_long(argc, argv, "hvnVDd:p:P:l:t:", lopt, 0)) != -1) {
  while ((option = getopt_long(argc, argv, "hvnVDd:p:P:l:m:", lopt, 0)) != -1) {
    switch (option) {
    switch (option) {
    case 'h':
    case 'h':
      usage(*argv, std::cout);
      usage(*argv, std::cout);
@@ -86,8 +83,8 @@ Option &Option::load(int argc, char *argv[]) {
    case 'p':
    case 'p':
      port = atoi(optarg);
      port = atoi(optarg);
      break;
      break;
    case 't':
    case 'm':
      maxthread = atoi(optarg);
      maxconn = atoi(optarg);
      break;
      break;
    case 'd':
    case 'd':
      database = optarg;
      database = optarg;
@@ -106,9 +103,6 @@ Option &Option::load(int argc, char *argv[]) {
    case 'v':
    case 'v':
      verbose = true;
      verbose = true;
      break;
      break;
    case 'n':
      closefd = false;
      break;
    case '?':
    case '?':
      usage(*argv, std::cerr);
      usage(*argv, std::cerr);
      exit(ERR_USAGE);
      exit(ERR_USAGE);
@@ -124,19 +118,46 @@ Option &Option::load(int argc, char *argv[]) {
}
}


Option &Option::loadenv() {
Option &Option::loadenv() {
//   const char *senv;
  const char *senv;

  // Get log file path
  if ((senv = getenv("SLS_LOG_FILE")) != 0 && *senv != 0)
    logfile = senv;

  // Get pid file path
  if ((senv = getenv("SLS_PID_FILE")) != 0 && *senv != 0)
    pidfile = senv;


//   // Get history path
  // Get DB file path
//   if ((senv = getenv("SLC_HISTORY_FILE")) != 0 && *senv != 0)
  if ((senv = getenv("SLS_DB_FILE")) != 0 && *senv != 0)
//     history_file = senv;
    database = senv;


//   // Get history size
  // Get port
//   if ((senv = getenv("SLC_HISTORY_SIZE")) != 0 && *senv != 0)
  if ((senv = getenv("SLS_PORT")) != 0 && *senv != 0)
//     history_size = atoi(senv);
    port = atoi(senv);


//  // Get log size
  // Get max connection
//   if ((senv = getenv("SLC_LOG_SIZE")) != 0 && *senv != 0)
  if ((senv = getenv("SLS_MAX_CONN")) != 0 && *senv != 0)
//     log_size = atoi(senv);
    maxconn = atoi(senv);

  // Get debug state
  if ((senv = getenv("SLS_DEBUG")) != 0) {
    daemon = false;
    verbose = true;
  }

  // Get verbose state
  if ((senv = getenv("SLS_VERBOSE")) != 0)
    verbose = true;


  return *this;
  return *this;
}
}

void Option::print(ostream &s) const {
  s << "Database file: " << database << std::endl
    << "Log file: " << logfile << std::endl
    << "Pid file: " << pidfile << std::endl
    << "TCP Port: " << port << std::endl
    << "Max conn: " << maxconn << std::endl
    << "Debug mode: " << !daemon << std::endl;
}
+2 −3
Original line number Original line Diff line number Diff line
@@ -27,18 +27,17 @@ struct Option {


  void usage(const char *name, ostream &out) const;
  void usage(const char *name, ostream &out) const;


  friend ostream &operator<<(ostream &, const Option &);
  void print(ostream &s = std::cout) const;


  bool verbose;
  bool verbose;
  string database;
  string database;


  // socket option
  // socket option
  int port;
  int port;
  size_t maxthread;
  size_t maxconn;


  // daemon options
  // daemon options
  bool daemon;
  bool daemon;
  bool closefd;
  string pidfile;
  string pidfile;
  string logfile;
  string logfile;


Loading