/******************************************************************************* * Copyright (c) 2007, Perforce Software, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE * SOFTWARE, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. *******************************************************************************/ /* * p4dctlerr.cc - definitions of errors for p4dctl */ # include <stdhdrs.h> # include <error.h> # include <errornum.h> # include <strbuf.h> # include "p4dctlerr.h" // // Error numbers are allocated like this: // // Fatal Errors: 001 - 200 // Failed Errors: 201 - 400 // Warnings: 401 - 600 // Info messages: 601 - 800 // Empty messages: 801 - 1000 // // Maximum is 1023 as 10 bits are allocated. // // Fatal errors // Failed command errors ErrorId CtlErr::BadCommand = { ErrorOf( ES_SERVER, 201, E_FAILED, EV_USAGE, 1), "Unrecognised command: %cmd%." }; ErrorId CtlErr::MissingRequiredParm = { ErrorOf( ES_SERVER, 202, E_FAILED, EV_USAGE, 3), "Configuration for %name% %type% is missing required parameter %parm%." }; ErrorId CtlErr::ServerAccessDenied = { ErrorOf( ES_SERVER, 203, E_FAILED, EV_USAGE, 3), "Access to %type% %name% owned by %user% denied." }; ErrorId CtlErr::NoRootServers = { ErrorOf( ES_SERVER, 204, E_FAILED, EV_USAGE, 0), "Servers owned by root are not permitted." }; ErrorId CtlErr::ConfigParseError = { ErrorOf( ES_SERVER, 205, E_FAILED, EV_USAGE, 2), "Syntax error in %configFile% at line %lineNo%." }; ErrorId CtlErr::NoServersConfigured = { ErrorOf( ES_SERVER, 206, E_FAILED, EV_USAGE, 0), "No servers configured." }; ErrorId CtlErr::ChildKilled = { ErrorOf( ES_SERVER, 207, E_FAILED, EV_FAULT, 2), "Child process %pid% exited on signal %signal%." }; ErrorId CtlErr::ChildFailed = { ErrorOf( ES_SERVER, 208, E_FAILED, EV_FAULT, 2), "'%cmd%' exited with status %status%." }; ErrorId CtlErr::ChildExecFail = { ErrorOf( ES_SERVER, 209, E_FAILED, EV_CONFIG, 1), "Failed to exec() %prog%." }; ErrorId CtlErr::SomeFailedStops = { ErrorOf( ES_SERVER, 210, E_FAILED, EV_FAULT, 0), "Not all servers stopped successfully." }; ErrorId CtlErr::SomeFailedStarts = { ErrorOf( ES_SERVER, 211, E_FAILED, EV_FAULT, 0), "Not all servers started successfully." }; ErrorId CtlErr::UnsafeConfig = { ErrorOf( ES_SERVER, 212, E_FAILED, EV_USAGE, 0), "Not safe to use configuration file or pid location from command line\n" "\twhen running as root." }; ErrorId CtlErr::CheckpointFail = { ErrorOf( ES_SERVER, 213, E_FAILED, EV_FAULT, 1), "Checkpointing %name% server failed. This needs investigation!" }; ErrorId CtlErr::RotateFail = { ErrorOf( ES_SERVER, 214, E_FAILED, EV_FAULT, 1), "Journal rotation for %name% server failed. This needs investigation!" }; // Warnings ErrorId CtlErr::SkippedServer = { ErrorOf( ES_SERVER, 401, E_WARN, EV_USAGE, 3), "Skipped %name% %type% owned by %owner%." }; ErrorId CtlErr::ServerNotRunning = { ErrorOf( ES_SERVER, 402, E_WARN, EV_USAGE, 2), "%name% %type% not running." }; ErrorId CtlErr::AlreadyRunning = { ErrorOf( ES_SERVER, 403, E_WARN, EV_USAGE, 2), "%name% %type% already running." }; // Informational messages ErrorId CtlErr::StartedServer = { ErrorOf( ES_SERVER, 601, E_INFO, EV_USAGE, 2), "Started %name% %type%." }; ErrorId CtlErr::StartedServers = { ErrorOf( ES_SERVER, 602, E_INFO, EV_USAGE, 1), "Started %count% servers." }; ErrorId CtlErr::StoppedServer = { ErrorOf( ES_SERVER, 603, E_INFO, EV_USAGE, 2), "Stopped %name% %type% server." }; ErrorId CtlErr::StoppedServers = { ErrorOf( ES_SERVER, 604, E_INFO, EV_USAGE, 1), "Stopped %count% servers." }; ErrorId CtlErr::ServerRunning = { ErrorOf( ES_SERVER, 605, E_INFO, EV_USAGE, 2), "%name% %type% is running." }; ErrorId CtlErr::KillingServer = { ErrorOf( ES_SERVER, 606, E_INFO, EV_USAGE, 2), "Failed to stop %name% %type% using 'p4 admin stop'. Trying a SIGTERM..." }; ErrorId CtlErr::Checkpointing = { ErrorOf( ES_SERVER, 607, E_INFO, EV_USAGE, 1), "Checkpointing %name% server..." }; ErrorId CtlErr::JnlRotate = { ErrorOf( ES_SERVER, 608, E_INFO, EV_USAGE, 1), "Rotating journal for %name% server..." }; ErrorId CtlErr::UsageMain = { ErrorOf( ES_SERVER, 650, E_INFO, EV_USAGE, 0), "\n" "Usage: p4dctl [global flags] <cmd> [flags] [server name]\n" "\n" "Global Flags\n" "------------\n" "\n" "-c <cfg_file> - Path to configuration file. Defaults to /etc/p4d.conf\n" "-p <pid_dir> - Path to pid file directory. Defaults to /var/run\n" "-q - Send output to syslog instead of stdout/stderr\n" "-v <level> - Set debug level to <level> (1-9)\n" "-V - Print version and exit\n" "\n" "Commands\n" "--------\n" "\n" "start - Start the specified server(s)\n" "stop - Stop the specified server(s)\n" "restart - Restart the specified server(s)\n" "status - Check the status of the specified server(s)\n" "checkpoint - Checkpoint the specified p4d server(s)\n" "journal - Rotate p4d server(s) journal file\n" "\n" }; ErrorId CtlErr::UsageStart = { ErrorOf( ES_SERVER, 651, E_INFO, EV_USAGE, 0), "\n" "Usage: p4dctl start [-t <type>] <server name>\n" " p4dctl start [-t <type>] -a\n" "\n" "Without the -a flag, starts a specific server; with the -a flag, starts\n" "all configured servers that the running user has permission to start.\n" "\n" "If the -t flag is specified, then only servers of the specified type\n" "will be started.\n" "\n" }; ErrorId CtlErr::UsageStop = { ErrorOf( ES_SERVER, 652, E_INFO, EV_USAGE, 0), "\n" "Usage: p4dctl stop [-t <type>] <server name>\n" " p4dctl stop [-t <type>] -a\n" "\n" "Without the -a flag, stops a specific server; with the -a flag, stops\n" "all configured servers that the running user has permission to stop.\n" "\n" "If the -t flag is specified, then only servers of the specified type\n" "will be stopped.\n" "\n" }; ErrorId CtlErr::UsageRestart = { ErrorOf( ES_SERVER, 653, E_INFO, EV_USAGE, 0), "\n" "Usage: p4dctl restart [-t <type>] <server name>\n" " p4dctl restart [-t <type>] -a\n" "\n" "Without the -a flag, restarts a specific server; with the -a flag, restarts\n" "all configured servers that the running user has permission to restart.\n" "\n" "If the -t flag is specified, then only servers of the specified type\n" "will be restarted.\n" "\n" }; ErrorId CtlErr::UsageStatus = { ErrorOf( ES_SERVER, 654, E_INFO, EV_USAGE, 0), "\n" "Usage: p4dctl status [-t <type>] <server name>\n" " p4dctl status [-t <type>] -a\n" "\n" "Without the -a flag, checks a specific server; with the -a flag, checks\n" "all configured servers that the running user has permission to check.\n" "\n" "If the -t flag is specified, then only servers of the specified type\n" "will be checked.\n" "\n" }; ErrorId CtlErr::UsageCheckpoint = { ErrorOf( ES_SERVER, 655, E_INFO, EV_USAGE, 0), "\n" "Usage: p4dctl checkpoint <server name>\n" " p4dctl checkpoint -a\n" "\n" "Without the -a flag, checkpoints a specific p4d server; with the -a flag,\n" "checkpoints all configured p4d servers that the running user has permission\n" "to checkpoint.\n" "\n" }; ErrorId CtlErr::UsageJournal = { ErrorOf( ES_SERVER, 656, E_INFO, EV_USAGE, 0), "\n" "Usage: p4dctl journal <server name>\n" " p4dctl journal -a\n" "\n" "Without the -a flag, rotates the journal of a specific p4d server; with the\n" "-a flag, rotates the journals of all configured p4d servers that the running\n" "user has permission to administer.\n" "\n" };
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 7841 | brett |
Initial branch of the Unix Perforce Server Control tool. See if this can be made to operate under Windows. |
||
//guest/tony_smith/perforce/p4dctl/src/p4dctlerr.cpp | |||||
#1 | 5945 | Tony Smith |
Release p4dctl, a program for starting/stopping Perforce services on Unix operating systems. Similar to, and developed in concert with, Sven Erik Knop's p4dcfg. For example: p4dctl start -a Can start multiple P4D, P4P, P4Web, or P4FTP servers in one easy command line. It can be executed by root, or by the 'owners' of the configured services and it maintains pidfiles no matter who uses it (so they remain accurate). An init script using p4dctl will typically just use: p4dctl start -a p4dctl stop -a p4dctl restart -a And check the exit status. |