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 Diff line number Diff line
@@ -24,6 +24,8 @@ sls_SOURCES= src/sls.hh \
		src/option.cc		\
		src/database.hh		\
		src/database.cc		\
		src/cron.hh		\
		src/cron.cc		\
		src/server.hh		\
		src/server.cc

sls/trunk/src/cron.cc

0 → 100644
+20 −0
Original line number 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 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 Diff line number Diff line
@@ -29,9 +29,8 @@ Option::Option() {
  verbose = false;
  database = "/var/db/sls.db";
  port = 18136;
  maxthread = 200;
  maxconn = 200;
  daemon = true;
  closefd = true;
  logfile = "/var/log/sls";
  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 | --version        : Print version and exit." << 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
      << "-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
      << "-n | --no-close       : Don't close stdin,stdout and stderr." << std::endl;
      << "-D | --debug          : Run with verbose and not in daemon mode." << std::endl;
}

/*!
@@ -69,16 +67,15 @@ Option &Option::load(int argc, char *argv[]) {
    {"verbose", 0, 0, 'v'},
    {"version", 0, 0, 'V'},
    {"port", 0, 0, 'p'},
    {"max-thread", 0, 0, 't'},
    {"max-conn", 0, 0, 'm'},
    {"pid-file", 0, 0, 'P'},
    {"log-file", 0, 0, 'l'},
    {"debug", 0, 0, 'D'},
    {"no-close", 0, 0, 'n'},
    {0, 0, 0, 0},
  };
  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) {
    case 'h':
      usage(*argv, std::cout);
@@ -86,8 +83,8 @@ Option &Option::load(int argc, char *argv[]) {
    case 'p':
      port = atoi(optarg);
      break;
    case 't':
      maxthread = atoi(optarg);
    case 'm':
      maxconn = atoi(optarg);
      break;
    case 'd':
      database = optarg;
@@ -106,9 +103,6 @@ Option &Option::load(int argc, char *argv[]) {
    case 'v':
      verbose = true;
      break;
    case 'n':
      closefd = false;
      break;
    case '?':
      usage(*argv, std::cerr);
      exit(ERR_USAGE);
@@ -124,19 +118,46 @@ Option &Option::load(int argc, char *argv[]) {
}

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
//   if ((senv = getenv("SLC_HISTORY_FILE")) != 0 && *senv != 0)
//     history_file = senv;
  // Get DB file path
  if ((senv = getenv("SLS_DB_FILE")) != 0 && *senv != 0)
    database = senv;

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

//  // Get log size
//   if ((senv = getenv("SLC_LOG_SIZE")) != 0 && *senv != 0)
//     log_size = atoi(senv);
  // Get max connection
  if ((senv = getenv("SLS_MAX_CONN")) != 0 && *senv != 0)
    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;
}

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 Diff line number Diff line
@@ -27,18 +27,17 @@ struct Option {

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

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

  bool verbose;
  string database;

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

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

Loading