store pid of process and return instead of exit into Sac_a_push::run method
[brisk.git] / web / spush / brisk-spush.php
1 #!/usr/bin/php
2 <?php
3 /*
4  *  brisk - spush/brisk-spush.php
5  *
6  *  Copyright (C) 2012 Matteo Nastasi
7  *                          mailto: nastasi@alternativeoutput.it 
8  *                                  matteo.nastasi@milug.org
9  *                          web: http://www.alternativeoutput.it
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * General Public License for more details. You should have received a
20  * copy of the GNU General Public License along with this program; if
21  * not, write to the Free Software Foundation, Inc, 59 Temple Place -
22  * Suite 330, Boston, MA 02111-1307, USA.
23  *
24  */
25
26 $G_base = "../";
27
28 require_once($G_base."Obj/sac-a-push.phh");
29 require_once("./brisk-spush.phh");
30 require_once($G_base."Obj/user.phh");
31 require_once($G_base."Obj/brisk.phh");
32 require_once($G_base."Obj/auth.phh");
33 require_once($G_base."Obj/zlibstream.phh");
34 // require_once("../Obj/proxyscan.phh");
35 require_once($G_base."index.php");
36 require_once($G_base."index_wr.php");
37 require_once($G_base."briskin5/Obj/briskin5.phh");
38 require_once($G_base."briskin5/index.php");
39 require_once($G_base."briskin5/index_wr.php");
40
41
42 function main()
43 {
44     pid_save();
45     do {
46         if (($room = Room::create(LEGAL_PATH."/brisk-crystal.data")) == FALSE) {
47             log_crit("room::create failed");
48             $ret = 1;
49             break;
50         }
51
52         if (($s_a_p = Sac_a_push::create($room, USOCK_PATH, 0, 0)) === FALSE) {
53             $ret = 2;
54             break;
55         }
56
57         $ret = $s_a_p->run();
58     } while (0);
59
60     pid_remove();
61     exit($ret);
62 }
63
64 main();
65 ?>