You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
1.4 KiB
C

#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <stdbool.h>
#include <unistd.h>
#include <signal.h>
#include <sys/prctl.h>
#include "model.h"
#include "model/server.h"
#include "process.h"
#include <curl/curl.h>
#include <stdlib.h>
#include <time.h>
bool terminate = false;
void handle_ctrl_c(int)
{
terminate = true;
}
int main( int argc, char* argv[], char* envp[] )
{
srand( time(NULL) );
curl_global_init(CURL_GLOBAL_DEFAULT);
model_init();
signal(SIGINT, handle_ctrl_c);
signal(SIGPIPE, SIG_IGN);
if( !app_args_new( argc, argv ) ) {
return 1;
}
int code = 0;
if( g_server->section == -1 ) {
printf( "Starting Apogee ActivityPub server...\n" );
printf( "Using port %d for web server\n", g_server->http_settings.bind_port );
// Tor
process_start_section(6);
// Make sure we have a hidden service hostname
FILE* f = fopen( "data/tor/hidden_service/hostname", "r" );
if( !f ) {
sleep(3);
} else {
fclose(f);
}
// Web servers
process_start_section(0);
process_start_section(0);
process_start_section(0);
// Inbox
process_start_section(1);
// Outbox
process_start_section(2);
// Fetch
process_start_section(5);
process_wait_for_finished();
printf( "Apogee server shutting down...\n" );
code = EXIT_SUCCESS;
} else {
printf( "section = %d\n", g_server->section );
process_run_section( g_server->section );
}
curl_global_cleanup();
app_args_release(g_server);
return code;
}