Files
@ 7eabd89b211a
Branch filter:
Location: DistRen/src/server/distrend.c
7eabd89b211a
5.4 KiB
text/plain
More edits, execs, etc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | /*
Copyright 2008 Nathan Phillip Brink, Ethan Zonca
This file is a part of DistRen.
DistRen is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DistRen 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with DistRen. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mysql.h>
#include <stdio.h>
/* Just some notes -- Ethan Zonca
*
* So I read the IRC transcript, and we need some communication and plugin (e.g., blender, povray) standards.
* In addition to those standards, we should also have standards for information availability,
* making statistics and remote control of each plugin or the whole system standard and common,
* so other apps can grab stats from it (such as a j2me phone DistRen status app or a php web
* interface).
*
*
*
* Notes from IRCness:
* Server<==>Client Communication
* Job initiation: <jobnumber> <jobtype={blender,povray,indigo,etc}> <filename> <args specific to the jobtype>
* Job addition : <jobnumber> <alteration: could be (cancel):cancel job (frames):tell the client to render more
frames>
* Client Control: system <command> (such as drop all jobs, shutdown client, etc)
*
* blender_getframecount()
* indigo_getframecount() always return 1... or just not bother with it?
*
* Upload while rendering
*
*
*/
// mySql configuration vars
static char *opt_host_name = "localhost"; // Server Hostname
static char *opt_user_name = "distren"; // Username
static char *opt_password = "008987"; // Password
static unsigned int opt_port_num = 0; // Port (or builtin if 0)
static char *opt_socket_name = NULL; // Socket Name (or builtin if null)
static char *opt_db_name = "distrend"; // Database name
static unsigned int opt_flags = 0; // Connection flags, what are these for?
static MYSQL *conn; // Pointer to the connection handler
int main(int argc, char *argv[])
{
// It's a happy fun mySQL party! This just test-connects to the server and does absolutely nothing else. Hopefully.
/* initialize connection handler */
conn = mysql_init (NULL);
if (conn == NULL)
{
fprintf (stderr, "mysql_init() failed (probably out of memory)\n");
return 1;
}
/* connect to server */
if (mysql_real_connect (conn, opt_host_name, opt_user_name, opt_password,
opt_db_name, opt_port_num, opt_socket_name, opt_flags) == NULL)
{
fprintf (stderr, "mysql_real_connect() failed\n");
mysql_close (conn);
return 1;
}
/* disconnect from server */
mysql_close (conn);
return 0;
}
/* The (mostly psuedo) Blender Rendering Code, by Ethan Zonca:
/////////////////////// MASTER ///////////////////////////////
// MySQL Setup Code (put in common maybe). Even though you don't want to use mysql, I'm going to write it anyway. Clients can be compiled without mysql...
#include <mysql.h>
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
//
char *server = "localhost"; // change if/when we do the multiserver setup... then distributed mysql with ssl? haha
char *user = "mysql";
char *password = "mysql"; // heh
char *database = "distrend"; // check... I think this exists already on my server(s)
//
conn = mysql_init(NULL);
if (!mysql_real_connect(conn, server, user, password, database, 0, NULL, 0)) { fprintf(stderr, "%s\n", mysql_error(conn)); return (0); }
// Queuer
void queue(char *filename, int priority, char name, char submitter, char contact) {
// Todo... store frame status in mysql tables, along with table with list of jobs/submitters/contact info/whatever else we want
/* Create a table with a row for each job, and a column for each frame. Rows will be ordered by priority. Each cell will have a status of
* "0" - cancelled
* "1" - not queued
* "2" - queued / assigned to slave
* "3" - completed by slave and uploaded
// Have a script crawl through each job, ordered by priority, and assign a certain number of frames
// to each slave. Then we will need some sort of watchdog to monitor slaves.
/*
}
///////////////////////// SLAVE ///////////////////////////////
// Slave listens on server for a command in the format of each function...
// We need if's for returns... ==> watchdog
// Executors
void exec_blender(char *input, char *output, int sframe, int eframe) {
int ret;
char *cmd[] = { "blender", "-b", "-o", output, input, "-s", sframe, "-e", eframe, (char *)0 };
ret = execv ("/usr/bin/blender", cmd);
}
void exec_luxrender_single(char *input, char *output) {
int ret;
char *cmd[] = { "luxrender", "-something", "something", "something", (char *)0 };
ret = execv {"/usr/bin/luxrender", cmd);
}
void exec_luxrender_anim(char *input, char *output, int sframe, int eframe, int spp) {
// spp is samples per pixel limitation on each frame
int ret;
char *cmd[] = { "luxrender", "-something", "something", "something", (char *)0 };
ret = execv {"/usr/bin/luxrender", cmd);
}
void exec_imagemagick {char *input, char *output, char *opts) {
int ret;
char *cmd[] = { "imagemagick", "-something", "something", "something", (char *)0 };
ret = execv {"/usr/bin/imagemagick", cmd);
}
*/
|